[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.



    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);
                output.broadcast(new StringToken(lineBuffer.toString()));
    kepler-dev mailing list
    kepler-dev at ecoinformatics.org

More information about the Kepler-dev mailing list