FileInputStream In Java Example

Chapter: Java I/O Last Updated: 21-07-2016 18:12:23 UTC

Program:

            /* ............... START ............... */
                
import java.io.FileInputStream;

public class JavaFileInputStream {
	public static void main(String[] args) {

		try {
			FileInputStream stream = new FileInputStream("Javafile.txt");

			while (stream.available() > 0) {
				System.out.print((char) stream.read());
			}

			stream.close();

		} catch (Exception ex) {
			System.out.println(ex.getMessage());
		}
	}
}
                /* ............... END ............... */
        

Notes:

  • The Java.io.FileInputStream class obtains input bytes from a file in a file system.
  • FileInputStream(File file) - creates a FileInputStream by opening a connection to an actual file, the file named by the File object file in the file system.
  • FileInputStream(FileDescriptor fdObj) - creates a FileInputStream by using the file descriptor fdObj, which represents an existing connection to an actual file in the file system.
  • FileInputStream(String name) - creates a FileInputStream by opening a connection to an actual file, the file named by the path name name in the file system.

Tags

FileInputStream , Java, Java I/O

Similar Programs Chapter Last Updated
Hidden File Check In Java Example Java I/O 20-06-2016
FileWriter In Java Example Java I/O 21-07-2016
FileReader In Java Example Java I/O 21-07-2016
FileOutputStream In Java Example Java I/O 21-07-2016
DataOutputStream In Java Example Java I/O 21-07-2016
DataInputStream In Java Example Java I/O 21-07-2016
CharArrayWriter In Java Example Java I/O 13-04-2016
CharArrayReader In Java Example Java I/O 21-07-2016
ByteArrayOutputStream In Java Example Java I/O 21-07-2016
ByteArrayInputStream In Java Example Java I/O 21-07-2016
BufferedWriter In Java Example Java I/O 21-07-2016
BufferedReader In Java Example Java I/O 21-07-2016
BufferedOutputStream In Java Example Java I/O 21-07-2016
BufferedInputStream In Java Example Java I/O 21-07-2016
ProcessBuilder To Make System Calls In Java Java I/O 19-08-2017

1