I have a text file named read.txt that says "JAVA PROGRAMMING" and i want to copy it to another file named write.txt and replace the space into underscore like this: "JAVA_PROGRAMMING". Big thanks to anyone who would help :)
My code:
import java.io.*;
import java.util.*;
class Main {
public static void main(String arg[]) throws Exception {
FileReader fin = new FileReader("read.txt");
FileWriter fout = new FileWriter("write.txt");
int i;
while ((i = fin.read()) != -1) {
fout.write(i);
}
System.out.println("Successfully copied!");
fin.close();
fout.close();
}
}