Java FileInputStream ClassJava FileInputStream class obtains input bytes from a file. It is used for reading byte-oriented data (streams of raw bytes) such as image data, audio, video etc. You can also read character-stream data. But, for reading streams of characters, it is recommended to use FileReader class. Java FileInputStream class declarationLet's see the declaration for java.io.FileInputStream class: Java FileInputStream class methods
Java FileInputStream example 1: read single characterNote: Before running the code, a text file named as "testout.txt" is required to be created. In this file, we are having following content: Welcome to javatpoint. After executing the above program, you will get a single character from the file which is 87 (in byte form). To see the text, you need to convert it into character. Output: W Java FileInputStream example 2: read all charactersOutput: Welcome to javaTpoint
Next TopicJava BufferedOutputStream Class
|