public void parseSynonyms(String line, ArrayList<String> synonyms, File f){
try{
BufferedWriter fw = new BufferedWriter(new FileWriter(f));
fw.newLine();
Scanner scanner = new Scanner(line);
scanner.useDelimiter(" ");
while(scanner.hasNext()){
String s = scanner.next();
if (s.contains("[[")){
if (Memory.get().isDebugMode()) {
System.out.println(s);
}
fw.write(" " + s);
fw.flush();
fw.newLine();
synonyms.add(s);
}
}
fw.close();
}catch(FileNotFoundException e){
e.printStackTrace();
System.out.println("Criticial Error, Exiting.");
System.exit(0);
}catch(IOException e){
e.printStackTrace();
}
}
I can’t find anything wrong with this.
S does have a string in it. Not empty.
The file exists. In fact, the program creates it if it doesn’t.
It overwrites the file and empties it to add to insult.
How do I fix this?