Copy file character by character with FileReader and FileWriter
import java.io.FileReader;
import java.io.FileWriter;
class FileCopy {
public static void main(String args[]) throws Exception {
FileReader fr = new FileReader(args[0]);
// Create a file writer
FileWriter fw = new FileWriter(args[1]);
// Read and copy characters
int i;
while ((i = fr.read()) != -1) {
fw.write(i);
}
fw.close();
fr.close();
}
}
Related examples in the same category