Java IO Fundamentals Flashcards
what does the public static field “in” of java.lang.System class represents and what type is it?
Represent standard input and is of type java.io.InputStream
what does the public static field “out” and “err” of java.lang.System class represents and what type are they?
output and error streams. They are of type java.io.PrintStream
if you do not provide the intended input data type as expect by the format string, what exception you may get?
IllegalFormatConversionException
Whats the difference between Character Stream and Byte Streams?
- Character streams are meant for reading or writing to a character- or text-based IO such as text files, text documents, XML and HTML files while Byte Streams are meant for reading or wiriting to a binary data IO such as executable files, image files, and files in low level file format such as .zip, .class, .exe..
- Character streams data is dealt with 16-bit unicode class while Byte Streams is dealt with 1 byte (8 bits)
- For Character stream Input and output character streams are called readers and writers, while input and and output byte streams are called input streams and output streams
- Character streams uses abstract classes of Reader and Writer, for Byte Streams its classes are called InputStream and OutputStream
give a short description of the class StringReader deriving from the reader class
character stream that operates on a string
give a short description of the class InputStreamReader deriving from the reader class
bridge between character stream and byte streams
give a short description of the class FileReader deriving from the reader class
devired class of InputStreamReader that provides support for reading character files
give a short description of the class BufferedReader deriving from the reader class
adds buffering to the underlying character stream so there is no need to access the underlying file system for each read and write operation
give a short description of the class StringWriter deriving from the Writer class
a character stream that collects the output in a string buffer, which can be used for creating a string
give a short description of the class OutputStreamWriter deriving from the Writer class
this class is a bridge between character streams and byte streams
give a short description of the class FileWriter deriving from the Writer class
derived class of OutputStreamWriter that provides support for writing character files
give a short description of the class PrintWriter deriving from the Writer class
supports formatted printing of characters to the output character stream
What is the difference between Streams and Reader/Writers?
- The Stream classes are used for inputting all types of binary/byte data
- Reader and writers classes are used for inputting and outputting only characters and string data
Does PrintWriter has a PrintReader?
False
What are the four abstract classes that are parent of all Stream Classes?
- InputStream
- OutputStream
- Reader
- Writer