Hi,
I read a file into a string, change the first line and then write this string into a new file. I do this through the following code (a little bit shortened):
while(jspIterator.hasNext()){
String line = (String) jspIterator.next();
if (i == 0) {
if (line.startsWith("bla bla") && line.endsWith("yada")) {
line = line.replaceFirst("this", "that");
}
}
jspAsString += line;
i++;
}
FileWriter newJspWriter = new FileWriter(newJspFile);
newJspWriter.write(jspAsString);
Now the files written this way are either 32, 24, 16, 8 KByte big or completely empty. When debugging I see that the String is assembled correctly. When I print the variable jspAsString to the console it also appears correct.
Do you know why FileWriter behaves this way?