Some key points on the File System
What is a Path
String representation of a file/directory within the file system
What is the package of a File Class?
java.io.File
What is the File class used for?
What does the instance of the File class represents?
Path name of a particular file/directory
What can a File class cannot do? * very important
Cannot read/write data within the File system.
Can a File class used to represent directories?
Yes
What is a relative path and what is absolute path?
Which slashdoes Unix and windows use
Unix: /
Windows: \
What are the two options to retrieve the local seperator character?
Method to find whether the file exists or not?
file.exists()
What are the two constructors generally used for creating a file Instance
File file = new File(“C:\Dilli.txt”);
File file2 = new File(file, “hello\Dilli.txt”);
What is getName() does?
getName returns the name of the directory / file denoted by this path
What is getAbsolutePath()?
returns the absolute pathname String of the file/directory
lastModified()
returns the no of milliseconds since the epoch when the file was last modified
delete()
deletes the file/directory
If the pathname denotes a directory, then the directory must be empty in order to be deleted
mkdirs()
creates the directory named by this paths including any non-existent parent directories
listFiles()
returns the File[] Array returning the files on the directory
How can the contents of the file accessed/written?
Streams, which is a list of data elements presented sequentially
How to conceptually remember a Stream?
Think Stream as a long, never ending Stream of water with data presented one “wave” at a time
What are the three input streams java provides?
System.in, System.err, System.out
Difference b/w Streams and Reader/Writer classes?
Are Readers/Writers are streams?
Yes, even though their names doesnt contain Streams in it, they are streams
Why we use character Streams?