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

Answer:

Yes. Even if the file was not written by a Java program you can write a program to input the raw bytes and arrange them into what (you guess) is their intended order.


InputStream

InputStream hierarchy

To read a file about which you have little information you need to make some intelligent guesses. If the file was written by a Java program then you need to know what data types were used. Then you can use a subclass of InputStream to read bytes for that data type. If the file contains several data types and you don't know the order they were written, the problem is more difficult.

The diagram shows InputStream and some of its subclasses.

InputStream itself is an abstract class (hence, the dotted cloud in the diagram).

Not all of these streams are concerned with input from disk files. For example, PipedInputStream represents data coming in from another running program.


QUESTION 2:

If a file was written with DataOutputStream, what input stream do you suspect will be useful?