[forge-issues] [JBoss JIRA] (ROASTER-97) Reads into streams using a 64kb limited buffer

George Gastaldi (JIRA) issues at jboss.org
Mon Mar 7 12:23:00 EST 2016


     [ https://issues.jboss.org/browse/ROASTER-97?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

George Gastaldi moved FURNACE-110 to ROASTER-97:
------------------------------------------------

              Project: Roaster  (was: Forge: Furnace)
                  Key: ROASTER-97  (was: FURNACE-110)
          Component/s: JDT
                           (was: Runtime)
    Affects Version/s: 2.18.3.Final
                           (was: 2.23.2.Final)
        Fix Version/s: 2.18.4.Final
                           (was: 2.23.3.Final)


> Reads into streams using a 64kb limited buffer
> ----------------------------------------------
>
>                 Key: ROASTER-97
>                 URL: https://issues.jboss.org/browse/ROASTER-97
>             Project: Roaster
>          Issue Type: Enhancement
>          Components: JDT
>    Affects Versions: 2.18.3.Final
>            Reporter: Claus Ibsen
>            Assignee: George Gastaldi
>            Priority: Minor
>             Fix For: 2.18.4.Final
>
>
> Was tracking down loading file content into as a string or input stream using forge, and got into the furnance source code
> {code}
> package org.jboss.forge.furnace.util;
> import java.io.ByteArrayInputStream;
> import java.io.Closeable;
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.InputStreamReader;
> import java.io.OutputStream;
> import java.io.UnsupportedEncodingException;
> import java.nio.charset.Charset;
> public abstract class Streams {
>     public Streams() {
>     }
>     public static String toString(InputStream stream) {
>         StringBuilder out = new StringBuilder();
>         try {
>             char[] e = new char[65536];
>             InputStreamReader in = new InputStreamReader(stream, "UTF-8");
>             int read;
>             do {
>                 read = in.read(e, 0, e.length);
>                 if(read > 0) {
>                     out.append(e, 0, read);
>                 }
>             } while(read >= 0);
>         } catch (UnsupportedEncodingException var5) {
>             throw new RuntimeException(var5);
>         } catch (IOException var6) {
>             throw new RuntimeException(var6);
>         }
>         return out.toString();
>     }
> {code}
> This is a bit of waste if you load a 1kb file. 
> The JDK has a BufferedInputStream you can leverage. or a BufferedReader.



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the forge-issues mailing list