In this section, you will learn to convert the InputStream to a File with an example.
Convert InputStream to File
Here we are showing how to convert an InputStream to File.
To do so first read the file as InputStream using FileInputStream. Create FileOutputStream class object to retrieve the file from system for modification then convert the InputSteam into byte array before writing into file then pass this array to the input stream and finally the byte array into file. Now all the data from InputStream is written into the desired file.
The code of the program is given below:
import java.io.*;
|
The output of the program is given below:
C:\rajesh\io>javac InputStreamToFile.java C:\rajesh\io>java InputStreamToFile File is created....................... |