Java FileInputStream Class
In Java language, FileInputStream is used for reading data from the files.
public class FileInputStream extends InputStream
FileInputStream class methods
S.No | Method | Description |
---|---|---|
1 | protected void finalize()throws IOException {} | This method is used to cleans up the connection to the file. |
2 | public int available() | It is used to return the number of bytes that can be read from the input stream. |
3 | public void read(byte[] a) | It is used to read a.length bytes from the input stream into an array. It is returns the total number of bytes read. |
4 | public void read(int a) | It is used to read the specified byte of data from the file Input stream. |
5 | public void close() | This method is used to closes the file output stream. |
Example:
import java.io.*; public class FileOutputStreamDemo{ public static void main(String args[]){ try { FileInputStream in = new FileInputStream("Inp.txt"); int i=0; while((i=in.read())!=-1){ System.out.print((char)i); } }catch(Exception e){ System.out.println(e); } finally { in.close(); } } }
Output
Welcome
Quickly Find What You Are Looking For
Onlinetpoint is optimized for basic learning, practice and more. Examples are well checked and working examples available on this website but we can't give assurity for 100% correctness of all the content. This site under copyright content belongs to Onlinetpoint. You agree to have read and accepted our terms of use, cookie and privacy policy.