CB-453: FileWriter.append - Chinese characters are not appended to the file correctly

This commit is contained in:
macdonst 2012-04-05 19:51:45 -04:00
parent 5d43835db8
commit cb473dfed4

View File

@ -973,23 +973,23 @@ public class FileUtils extends Plugin {
/**/ /**/
public long write(String filename, String data, int offset) throws FileNotFoundException, IOException { public long write(String filename, String data, int offset) throws FileNotFoundException, IOException {
filename = stripFileProtocol(filename); filename = stripFileProtocol(filename);
boolean append = false; boolean append = false;
if (offset > 0) { if (offset > 0) {
this.truncateFile(filename, offset); this.truncateFile(filename, offset);
append = true; append = true;
} }
byte [] rawData = data.getBytes(); byte [] rawData = data.getBytes();
ByteArrayInputStream in = new ByteArrayInputStream(rawData); ByteArrayInputStream in = new ByteArrayInputStream(rawData);
FileOutputStream out = new FileOutputStream(filename, append); FileOutputStream out = new FileOutputStream(filename, append);
byte buff[] = new byte[rawData.length]; byte buff[] = new byte[rawData.length];
in.read(buff, 0, buff.length); in.read(buff, 0, buff.length);
out.write(buff, 0, rawData.length); out.write(buff, 0, rawData.length);
out.flush(); out.flush();
out.close(); out.close();
return data.length(); return rawData.length;
} }
/** /**