ByteStrems
FileInputStream - FileOutputStream
Chracter Stream
FileReader - FileWriter (Char by char access)
BufferedReader - PrintWriter (pass FileWriter obj, and get line by line access)
DataStream
DataInputStream - DataOutputStream
Object Stream
ObjectInputStream - ObjectOutputStream.
Q- If the input is a stream of bytes. Why FileInputStream.read() method return int value instead of byte ?
Ans: Using a int as a return type allows read() to use -1 to indicate that it has reached the end of the stream.
Q- Diff between Buffered and UnBuffered I/O ?
UnBuffered : each read or write request is handled directly by the underlying OS. This can make a program much less efficient, since each such request often triggers disk access, network activity, or some other operation that is relatively expensive.
Buffered : Buffered input streams read data from a memory area known as a buffer; the native input API is called only when the buffer is empty. Similarly, buffered output streams write data to a buffer, and the native output API is called only when the buffer is full.
Q- What are the Buffered Stream classes used to wrap unbuffered streams ?
There are following four classes
BufferedInputStream - BufferedOutputStream
BufferedReader - BufferedWriter
Q- What is purpose of Scanner class ?
Ans - Scanner are useful for breaking down formatted input into tokens and translating individual tokens according to their data type.
By default, a scanner uses white space to separate tokens. (White space characters include blanks, tabs, and line terminators).
http://docs.oracle.com/javase/tutorial/essential/io/scanning.html
Q- What is purpose of Console class ?
Ans- Console class is an advanced alternative to Standard Streams. It provides most of the features provided by Standard Streams and others besides.
For ex. Console object supports secure password entry.
http://docs.oracle.com/javase/tutorial/essential/io/cl.html
Q- What are Data Streams ?
Data streams support binary I/O of primitive data type values (boolean, char, byte, short, int, long, float, and double) as well as String values. All data streams implement either the DataInput interface or the DataOutput interface.
it provide you methods like,
DataInputStream.readDouble - DataOutputStream.writeDouble
DataInputStream.readInt - DataOutputStream.writeInt
etc.
Q- What are Object Streams ?
Just as data streams support I/O of primitive data types, object streams support I/O of objects. Most, but not all, standard classes support serialization of their objects. Those that do implement the marker interface Serializable.
The object stream classes are ObjectInputStream and ObjectOutputStream.
writeObject and readObject methods used to read and write objects.
Q- What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
The Reader/Writer class hierarchy is character-oriented and the InputStream/OutputStream class hierarchy is byte-oriented.
Q- What's the difference between a file's path, absolute path, and canonical path?
Refer Here
No comments:
Post a Comment