
java program using fileinputstream and fileoutputstream

Hi Friend,
Try the following code:
import java.io.*;
class FileInputStreamAndFileOutputStream
{
public static void main(String[] args) throws Exception {
FileInputStream in = new FileInputStream("c:/hello.txt");
FileOutputStream out = new FileOutputStream("C:/data.txt");
int c;
while ((c = in.read()) != -1) {
out.write(c);
}
out.close();
System.out.println("File is copied");
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.