114 Program to copy from one file to another file in Java

Code:
/* Program to copy data from one file to other */
import java.io.*;

class CopyDemo
{
public static void main(String args[]) throws IOException,FileNotFoundException
{
FileInputStream fis = new FileInputStream("Original.txt");

FileOutputStream fos = new FileOutputStream("Copy.txt");

int data = fis.read();

while(data != -1)
{
fos.write((char)data);

data = fis.read();
}
System.out.println("Copied Completed");
fos.close();
}

}

Ouput:

copy from one file to another file in Java

Previous
Next Post »