import java.io.*; public class FileReaderWriterExample { public static void main(String[] args) throws IOException { // Create input stream object. FileInputStream fis = new FileInputStream("Data"); // Create output stream object. FileOutputStream fout = new FileOutputStream("Data2"); // Set variable for looping through bytes. int c; // Loop to read and write bytes. while ((c = fis.read()) != -1) fout.write(c); // Close output and input resources. fis.close(); fout.close(); } }