read, readline, close method, FileInputStream, FileOutputStream class in Java

read method: To read characters read() method is used. Read method is used to read a character from an input stream. It returns an integer value, it returns -1 for end of stream.


int read( ) throws IOException

readline method: readline() method: It is used to read strings from the keyboard.


String readLine( ) throws IOException

close method: It is used to close a file.


void close( ) throws IOException

FileInputStream class: It is used to read from files.

Types of constructors defined by  FileInputStream class:

FileInputStream(String path)

FileInputStream(File ob)

FileOutputStream class: It is used to write to files.

Types of constructors defined by  FileOutputStream class:

FileOutputStream(String path)

FileOutputStream(File ob)

FileOutputStream(String path, boolean append)

FileOutputStream(File ob, boolean append)

Leave a Reply