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();
}
}
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();
}
}