Loading, please wait...

A to Z Full Forms and Acronyms

Read The Data from One File and Write The Data to another File using Java

This Program is used to demonstrate Read The Data from One File and Write The Data to another File using Java
import java.io.*; 
class file1 
{ 
public static void main(String arg[]) 
{ 
File inf = new File("in.dat"); 
File outf = new File("out.dat"); 

FileReader ins = null; 
FileWriter outs = null; 

try 
{ 
ins = new FileReader(inf); 
outs = new FileWriter(outf); 

int ch; 

while((ch=ins.read())!=-1) 
{ 
outs.write(ch); 
} 
}catch(IOException e) 
{ 
System.out.println(e); 
System.exit(-1); 
} 

finally 
{ 
try 
{ 
ins.close(); 
outs.close(); 
} 
catch(IOException e) 
{ } 
} 
} 
}
A to Z Full Forms and Acronyms

Related Article