I'm trying to read a file with .txt
extension to copy the words to another file.
The problem is that if the original file has accents or special characters, the program does not work.
public static void main(String[] args) {
String palabra;
Scanner input = null;
PrintStream output = null;
try {
input = new Scanner(new File("Quijote01.txt"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
output = new PrintStream(new File("Copia.txt"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
while(input.hasNext()){
palabra = input.next();
output.println(palabra);
}
}
What is the problem? Thanks.