From Exception, Stream and I/O chapter in PU/ Programming in Java
Asked on 2 Feb, 2021
0
1238 Views
import java.io.* ;
class ReadingAndWriting {
public static void main(String[] agrs)throws IOException{
FileInputStream fi = new FileInputStream("abc.txt") ;
FileOutputStream fo = new FileOutputStream("xyz.txt") ;
int readByte = 0 ;
while(true){
readByte = fi.read() ;
if(readByte == -1) break ;
fo.write(readByte) ;
}
System.out.println("Copied") ;
}
}
Add your answer