UnclosableInputStream extends InputStream { @Override public int read() throws IOException { return inputStream.read(); } UnclosableInputStream(InputStream inputStream); @Override int read(); @Override void close();  }
@Test public void simple() throws IOException { InputStream inputStream = new ByteArrayInputStream("Hello World!".getBytes()); try (InputStream content = new UnclosableInputStream(inputStream)) { ByteStreams.exhaust(content); } Assert.assertEquals(inputStream.read(), -1); }