Oracle
docs.oracle.com › javase › 8 › docs › api › java › io › FileInputStream.html
FileInputStream (Java Platform SE 8 )
March 16, 2026 - Java™ Platform Standard Ed. 8 ... A FileInputStream obtains input bytes from a file in a file system.
Videos
File Reading in Java using FileReader and FileInputStream
09:56
Java Tutorial #75 - Java File Input Stream Class Examples (File ...
02:53
What is FileInputStream in Java? | Java IO | Java Tutorial - YouTube
09:29
File IO in Java with Input and Output Streams and Writers - YouTube
Java Intermediate Tutorials #9 - Binary stream input
10:23
Learn Java Programming - FileInputStream Tutorial - YouTube
Oracle
docs.oracle.com › javase › 7 › docs › api › java › io › FileInputStream.html
FileInputStream (Java Platform SE 7 )
Java™ Platform Standard Ed. 7 ... A FileInputStream obtains input bytes from a file in a file system.
W3Schools
w3schools.com › java › java_fileinputstream.asp
Java FileInputStream
FileInputStream - best for binary data (images, audio, PDFs) or when you need full control of raw bytes. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
Oracle
docs.oracle.com › javase › 10 › docs › api › java › io › FileInputStream.html
FileInputStream (Java SE 10 & JDK 10 )
java.io.InputStream · java.io.FileInputStream · All Implemented Interfaces: Closeable, AutoCloseable · public class FileInputStream extends InputStream · A FileInputStream obtains input bytes from a file in a file system. What files are available depends on the host environment.
Mkyong
mkyong.com › home › java › how to read file in java – fileinputstream
How to read file in Java - FileInputStream - Mkyong.com
January 1, 2021 - Below is a text file containing 10 bytes. ... package com.mkyong.io.api.inputstream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class FileInputStreamExample2 { public static void main(String[] args) { readFile("c:\\test\\file.txt"); } private static void readFile(String fileName) { try (FileInputStream fis = new FileInputStream(new File(fileName))) { // remaining bytes that can be read System.out.println("Remaining bytes that can be read : " + fis.available()); int content; // reads a byte at a time, if end of the file, returns -1 while ((content = fis.read()) != -1) { System.out.println((char) content); System.out.println("Remaining bytes that can be read : " + fis.available()); } } catch (IOException e) { e.printStackTrace(); } } }
Oracle
docs.oracle.com › en › java › javase › › 11 › docs › api › java.base › java › io › FileInputStream.html
FileInputStream (Java SE 11 & JDK 11 )
January 20, 2026 - java.io.InputStream · java.io.FileInputStream · All Implemented Interfaces: Closeable, AutoCloseable · public class FileInputStream extends InputStream · A FileInputStream obtains input bytes from a file in a file system. What files are available depends on the host environment.
Jenkov
jenkov.com › tutorials › java-io › inputstream.html
Java InputStream
You can convert a Java InputStream to a Java Reader using the Java InputStreamReader. You can read more about how to use the InputStreamReader by clicking the link in the previous sentence, but here is a quick example of converting an InputStream to an InputStreamReader: InputStream inputStream = new FileInputStream("c:\\data\\input.txt"); Reader inputStreamReader = new InputStreamReader(inputStream);
Programiz
programiz.com › java-programming › fileinputstream
Java FileInputStream (With Examples)
The FileInputStream class of the java.io package can be used to read data (in bytes) from files. It extends the InputStream abstract class.
Top answer 1 of 8
133
You need to create new file and copy contents from InputStream to that file:
File file = //...
try(OutputStream outputStream = new FileOutputStream(file)){
IOUtils.copy(inputStream, outputStream);
} catch (FileNotFoundException e) {
// handle exception here
} catch (IOException e) {
// handle exception here
}
I am using convenient IOUtils.copy() to avoid manual copying of streams. Also it has built-in buffering.
2 of 8
99
In one line :
FileUtils.copyInputStreamToFile(inputStream, file);
(org.apache.commons.io)
GeeksforGeeks
geeksforgeeks.org › java › implement-how-to-load-file-as-inputstream-in-java
Implement how to load File as InputStream in Java - GeeksforGeeks
July 23, 2025 - The read() method of InputStream class, reads a byte of data from the input stream. The next byte of data is returned, or -1 if the end of the file is reached and throws an exception if an I/O error occurs. Refer to the program. ... // Importing generic Classes/Files import java.io.*; class GFG { // Main driver function public static void main(String[] args) { // Creating file object and specifying path File file = new File( "/Users/mayanksolanki/Desktop/Folder/test.txt"); try (FileInputStream input = new FileInputStream(file)) { int character; // read character by character // by default read() function return int between // 0 and 255.
Mkyong
mkyong.com › home › java › how to convert inputstream to file in java
How to convert InputStream to File in Java - Mkyong.com
December 27, 2020 - And we use FileOutputStream to copy the InputStream into a File, and save it somewhere. ... package com.mkyong.io.howto; import java.io.*; import java.net.URI; public class InputStreamToFile1 { /** * The default buffer size */ public static final int DEFAULT_BUFFER_SIZE = 8192; public static void main(String[] args) throws IOException { URI u = URI.create("https://www.google.com/"); try (InputStream inputStream = u.toURL().openStream()) { File file = new File("c:\\test\\google.txt"); copyInputStreamToFile(inputStream, file); } } private static void copyInputStreamToFile(InputStream inputStream, File file) throws IOException { // append = false try (FileOutputStream outputStream = new FileOutputStream(file, false)) { int read; byte[] bytes = new byte[DEFAULT_BUFFER_SIZE]; while ((read = inputStream.read(bytes)) != -1) { outputStream.write(bytes, 0, read); } } } }
Programiz
programiz.com › java-programming › examples › load-file-as-inputstream
Java Program to Load File as InputStream
import java.io.InputStream; import java.io.FileInputStream; public class Main { public static void main(String args[]) { try { // file input.txt is loaded as input stream // input.txt file contains: // This is a content of the file input.txt InputStream input = new FileInputStream("input.txt"); System.out.println("Data in the file: "); // Reads the first byte int i = input.read(); while(i != -1) { System.out.print((char)i); // Reads next byte from the file i = input.read(); } input.close(); } catch(Exception e) { e.getStackTrace(); } } }
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › io › FileInputStream.html
FileInputStream (Java SE 21 & JDK 21)
October 20, 2025 - java.io.InputStream · java.io.FileInputStream · All Implemented Interfaces: Closeable, AutoCloseable · public class FileInputStream extends InputStream · A FileInputStream obtains input bytes from a file in a file system. What files are available depends on the host environment.
Javatpoint
javatpoint.com › java-fileinputstream-class
Java FileInputStream Class
Java Class The is composed of two words: ByteArray and InputStream. As the name suggests, it can be used to read byte array as input stream. Java class contains an internal buffer which is used to read byte array as stream.