]
George Gastaldi moved FORGE-2603 to FURNACE-109:
------------------------------------------------
Project: Forge: Furnace (was: Forge)
Key: FURNACE-109 (was: FORGE-2603)
Component/s: Runtime
(was: Furnace (Container))
Affects Version/s: 2.23.2.Final
(was: 3.0.0.CR1)
Furnance - Reads into streams using a 64kb limited buffer
---------------------------------------------------------
Key: FURNACE-109
URL:
https://issues.jboss.org/browse/FURNACE-109
Project: Forge: Furnace
Issue Type: Enhancement
Components: Runtime
Affects Versions: 2.23.2.Final
Reporter: Claus Ibsen
Priority: Minor
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.