Java Code Examples for com.facebook.common.internal.Closeables#close()
The following examples show how to use
com.facebook.common.internal.Closeables#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CloseableReference.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
@Override public void release(Closeable value) { try { Closeables.close(value, true); } catch (IOException ioe) { // This will not happen, Closeable.close swallows and logs IOExceptions } }
Example 2
Source File: CloseableReference.java From fresco with MIT License | 5 votes |
@Override public void release(Closeable value) { try { Closeables.close(value, true); } catch (IOException ioe) { // This will not happen, Closeable.close swallows and logs IOExceptions } }
Example 3
Source File: SharedReferenceTest.java From fresco with MIT License | 5 votes |
@Override public void release(Thing value) { try { Closeables.close(value, true); } catch (IOException ioe) { // this should not happen Assert.fail(); } }
Example 4
Source File: StreamUtilTest.java From fresco with MIT License | 5 votes |
/** Verify that using a ByteArrayInputStream does not allocate a new byte array. */ @Test public void testByteArrayInputStream() throws Exception { byte[] bytes = new byte[8]; InputStream input = new ByteArrayInputStream(bytes); try { byte[] bytesRead = StreamUtil.getBytesFromStream(input); assertTrue(Arrays.equals(bytes, bytesRead)); } finally { Closeables.close(input, true); } }
Example 5
Source File: StreamUtilTest.java From fresco with MIT License | 5 votes |
/** Verify that using an offset with ByteArrayInputStream still produces correct output. */ @Test public void testByteArrayInputStreamWithOffset() throws Exception { byte[] bytes = new byte[] {0, 1, 2, 3, 4}; InputStream input = new ByteArrayInputStream(bytes, 1, 4); try { byte[] bytesRead = StreamUtil.getBytesFromStream(input); byte[] expectedBytes = new byte[] {1, 2, 3, 4}; assertTrue(Arrays.equals(expectedBytes, bytesRead)); } finally { Closeables.close(input, true); } }