Flashcards in JAVA IO Deck (59)
Some key points on the File System
1. A file is a record within the file system that stores data.
2. Files are organized into directories.
3. Directory is a record in the file system that contains files as well as dircetories
What is a Path
String representation of a file/directory within the file system
What is the package of a File Class?
What is the File class used for?
1. Read information about existing files and directories
2. list the content of a directory
3. create/delete files and directories
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?
What is a relative path and what is absolute path?
1. Relative path is the path from the current working directory to file or directory
2. Absolute Path is the path of file/directory from root directory
Which slashdoes Unix and windows use
What are the two options to retrieve the local seperator character?
1. System property
2. Static variable
Method to find whether the file exists or not?
What are the two constructors generally used for creating a file Instance
1. One is taking String as argument representing relative/absolute path
2. two arguments, one which is existing file path and other relative child path.
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
returns the no of milliseconds since the epoch when the file was last modified
deletes the file/directory
If the pathname denotes a directory, then the directory must be empty in order to be deleted
creates the directory named by this paths including any non-existent parent directories
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?
1. Stream classes are used for inputting and outputting all types of binary or byte data
2. Reader/Writer classes are used for inputting and outputting only character and String data
Are Readers/Writers are streams?
Yes, even though their names doesnt contain Streams in it, they are streams
Why we use character Streams?
1. There are advantages of using reader/writer clsses as they are specifically focussed on managing character and string data
2. WE DONT WANT TO WORRY ABOUT THE UNDERLYING BYTE ENCODING OF THE FILE
How can we differentiate streams as levels?
Low-Level Stream and High-Level Streams.
What is Low-level Streams?
Low level Streams connects directly with the source of the data such as files, arrays or Strings.
They process the raw data or resources and are accessed in a direct or unfiltered manner.
What are high level Sreams?
High level Streams is built on anoter Stream using wrapping. (An instance is passed as constructor to another instance)
What are the four abstract classes that are parent for all streams?
Which is the parent class of PrintStream?