I filed an issue
https://issues.apache.org/jira/browse/CAMEL-6701

Jan

> -----Ursprüngliche Nachricht-----
> Von: Jan Matèrne (jhm) [mailto:apa...@materne.de]
> Gesendet: Dienstag, 3. September 2013 09:05
> An: dev@camel.apache.org
> Betreff: Bug in IOHelper?
> 
> 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