IO: Open TemporaryBuffer.Heap in try-with-resource

Change-Id: I78a947fd1263b47b3df17bcc6e9b32497e68dd4a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
David Pursehouse 2019-01-21 14:19:29 +09:00
parent f5614e03f1
commit a0f69ff387
1 changed files with 7 additions and 6 deletions

View File

@ -203,12 +203,13 @@ public static ByteBuffer readWholeStream(InputStream in, int sizeHint)
if (last < 0)
return ByteBuffer.wrap(out, 0, pos);
@SuppressWarnings("resource" /* java 7 */)
TemporaryBuffer.Heap tmp = new TemporaryBuffer.Heap(Integer.MAX_VALUE);
tmp.write(out);
tmp.write(last);
tmp.copy(in);
return ByteBuffer.wrap(tmp.toByteArray());
try (TemporaryBuffer.Heap tmp = new TemporaryBuffer.Heap(
Integer.MAX_VALUE)) {
tmp.write(out);
tmp.write(last);
tmp.copy(in);
return ByteBuffer.wrap(tmp.toByteArray());
}
}
/**