Home » Core Java » io » FileInputStream

FileInputStream

java.io.FileInputStream Example

In this example we are going to see how to use FileInputStream in Java. FileInputStream in an InputStream subclass that is used to read data from files in a file system. It is actually connected to a specific files, and can be used to extract data from them and make them available inside your program for manipulation. As with InputStream, ...

Read More »

How to copy a directory in Java

In this tutorial we are going to see how you can copy a directory in Java. The idea is very simple. You open the directory and you list the contents. Then you open the contents and examine them one by one. If the entry you are looking at is a File, you can copy it to the new location. If ...

Read More »

Decompress a GZIP File in Java example

In the previous tutorial we saw how to compress a File with the GZIP method. In this tutorial we are going to see how to decompress the File that was compressed with the GZIP method. Basically all you have to do to decompress a gzipped file is: Create a FileInputStream to the compressed File. Create a GZIPInputStream to the above ...

Read More »

Compress a File in GZIP format in Java

In this tutorial we are going to see how you can compress a File in Java using the GZIP compression method. So, to perform File compression using GZIP in Java, you have to: Create a FileOutputStream to the destination file, that is the file path to the output compressed file. Create a GZIPOutputStream to the above FileOutputStream. Create a FileInputStream ...

Read More »

How to Read an Object from File in Java

In the previous tutorial we saw how to write an Object to a file in Java. In this example we are going to see how to read an Object from the file that we’ve stored it earlier. Basically, to read an Object from a file, one should follow these steps: Open a FileInputStream to the file that you’ve stored the ...

Read More »

4 Ways to Copy File in Java

Although Java offers a class that can handle file operations, that is java.io.File, it doesn’t have a copy method that will copy a file to another. The copying action is an important one, when your program has to handle many file related activities. Nevertheless, there are several ways you can perform a file copying operation in Java and we will ...

Read More »

Tokenizer from FileReader example

In this example we shall show you how to get a tokenizer from a FileReader. The FileReader is a convenience class for reading character files. The constructors of this class assume that the default character encoding and the default byte-buffer size are appropriate. To get a tokenizer from a FileReader one should perform the following steps: Create a new FileReader, ...

Read More »

Read file with FileInputStream

With this example we are going to demonstrate how to read a File with a FileInputStream. The FileInputStream obtains input bytes from a file in a file system. In short, to read a File with a FileInputStream you should: Create a new File instance by converting the given pathname string into an abstract pathname. Create a FileInputStream by opening a ...

Read More »

Read file in byte array with FileInputStream

This is an example of how to read a File in a byte array using a FileInputStream. The FileInputStream obtains input bytes from a file in a file system. Reading a file in a byte array with a FileInputStream implies that you should: Create a new File instance by converting the given pathname string into an abstract pathname. Create a ...

Read More »