[kepler-dev] string encodings
Christopher Brooks
cxh at eecs.berkeley.edu
Mon Aug 9 15:19:08 PDT 2004
I don't think StringToken was intended to handle raw binary data.
ptolemy/util/FileUtilities.java has a copyFile() method
that avoids end of line problems.
FileReader should probably handle raw binary data files.
-Christopher
--------
On Mon, 9 Aug 2004, Tobin Fricke wrote:
> I am using FileReader to read a binary file into a StringToken.
This is somewhat suspicious (in FileReader.java) -- note the silent
newline translation that makes FileReader break with binary files:
BufferedReader reader = fileOrURL.openForReading();
StringBuffer lineBuffer = new StringBuffer();
String newline = System.getProperty("line.separator");
while (true) {
String line = reader.readLine();
if (line == null) break;
lineBuffer = lineBuffer.append(line);
lineBuffer = lineBuffer.append(newline);
}
fileOrURL.close();
output.broadcast(new StringToken(lineBuffer.toString()));
--tobin
_______________________________________________
kepler-dev mailing list
kepler-dev at ecoinformatics.org
http://www.ecoinformatics.org/mailman/listinfo/kepler-dev
--------
More information about the Kepler-dev
mailing list