[kepler-dev] string encodings
Tobin Fricke
tobin at splorg.org
Mon Aug 9 15:11:19 PDT 2004
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
More information about the Kepler-dev
mailing list