I think this is a bug ...

org.apache.camel.util.IOHelper.loadText(InputStream)

 

If the textfile is a one liner without a LF at the end, this method still
appends a \n.

 

https://svn.apache.org/repos/asf/commons/proper/io/trunk/src/main/java/org/a
pache/commons/io/IOUtils.java uses an interim StringWriter and copies all
bytes (!) from the input stream to the SW.

 

Do you think that this is a bug too? Then I could open an issue.

 

 

Jan

 

 

 

    /**

     * Loads the entire stream into memory as a String and returns it.

     *

     * Warning, don't use for crazy big streams :)

     */

    public static String loadText(InputStream in) throws IOException {

        StringBuilder builder = new StringBuilder();

        try {

            BufferedReader reader = buffered(new InputStreamReader(in));

            while (true) {

                String line = reader.readLine();

                if (line != null) {

                    builder.append(line);

                    builder.append("\n");

                } else {

                    break;

                }

            }

            return builder.toString();

        } finally {

            close(in);

        }

    }

 

 

 

Reply via email to