go to previous page   go to home page   go to next page

Answer:

No. If the file does not open an IOException is thrown and then caught by the outer catch{} block


Reading and Writing Bytes

Usually data is much more complicated than the data for the example program. But the program shows the outer logic that is needed to read most files. Sometimes the data in a file represents something other than a primitive Java type. For example, word processor files contain various arrangements of bytes that encode fonts, page formats, special symbols, and graphics.

The DataOutputStream and DataInputStream classes have several methods for reading and writing single bytes.

writeByte() writes the least significant byte of its int argument to the output stream. readUnsignedByte() reads a byte from the input stream and puts it in the least significant byte of its return value.



DataOutputStream:
    public final void writeByte(int b) throws IOException

DataInputStream:
    public final int readUnsignedByte() throws IOException


QUESTION 14:

Could a byte read from a file by readUnsignedByte() be written to another file by writeByte().


go to previous page   go to home page   go to next page