import java.io.*;
public class OutputStreamDemo{
public static void main(String[] args){
FileInputStream fis = null;
FileOutputStream fos = null;
try{
fis = new FileInputStream("input.txt");
fos = new FileOutputStream("output.txt");
System.out.println("Available data "+fis.available()+" data");
int c = fis.read();
while(c!=-1){
fos.write((char)c);
c = fis.read();
}
}
catch(IOException ie){
ie.printStackTrace();
}
finally{
try{
if(fis!=null)
fis.close();
}
catch(IOException ie){
ie.printStackTrace();
}
try{
if(fos!=null)
fos.close();
}
catch(IOException ie){
ie.printStackTrace();
}
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter