Skip to content

Commit

Permalink
FURNACE-111: Streams should never attempt to close an open stream
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Mar 16, 2016
1 parent 16c9c71 commit cb5e3c6
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ public abstract class Streams
public static String toString(final InputStream stream)
{
StringBuilder out = new StringBuilder();
try (Reader in = new InputStreamReader(stream, "UTF-8"))
try
{
final char[] buffer = new char[8192];
Reader in = new InputStreamReader(stream, "UTF-8");
int read;
do
{
Expand Down Expand Up @@ -61,9 +62,10 @@ public static String toString(final InputStream stream)
public static String toString(final InputStream stream, Charset charset)
{
StringBuilder out = new StringBuilder();
try (Reader in = new InputStreamReader(stream, charset))
try
{
final char[] buffer = new char[8192];
Reader in = new InputStreamReader(stream, charset);
int read;
do
{
Expand All @@ -84,13 +86,13 @@ public static String toString(final InputStream stream, Charset charset)

public static void write(final InputStream source, final OutputStream destination)
{
try (InputStream is = source)
try
{
final byte[] buffer = new byte[8192];
int read;
do
{
read = is.read(buffer, 0, buffer.length);
read = source.read(buffer, 0, buffer.length);
if (read > 0)
{
destination.write(buffer, 0, read);
Expand Down

0 comments on commit cb5e3c6

Please sign in to comment.