@Test void close() { ByteArrayOutputStream stubStream = new ByteArrayOutputStream(0) { private boolean closed; @Override public synchronized void write(int b) { if (closed) { throw new RuntimeException("Stream is already closed"); } super.write(b); } @Override public synchronized void close() throws IOException { this.closed = true; super.close(); } }; IOUtils.close(stubStream); assertThrows(RuntimeException.class, () -> stubStream.write(0x00)); }
public static void close(@Nullable Closeable closeable) { close(closeable, null); }
IOUtils { public static void close(@Nullable Closeable closeable) { close(closeable, null); } }
IOUtils { public static void close(@Nullable Closeable closeable) { close(closeable, null); } private  IOUtils(); }
IOUtils { public static void close(@Nullable Closeable closeable) { close(closeable, null); } private  IOUtils(); static Result<String, IOException> fetchContent(String url); static Result<InputStream, IOException> fetchContentAsStream(String url); static InputStream convertStringToStream(String str); static Result<String, IOException> convertStreamToString(InputStream inputStream); static Result<String, IOException> convertStreamToString(InputStream inputStream, Charset encoding); static void close(@Nullable Closeable closeable); static void close(@Nullable Closeable closeable, @Nullable Consumer<IOException> exceptionConsumer); }
IOUtils { public static void close(@Nullable Closeable closeable) { close(closeable, null); } private  IOUtils(); static Result<String, IOException> fetchContent(String url); static Result<InputStream, IOException> fetchContentAsStream(String url); static InputStream convertStringToStream(String str); static Result<String, IOException> convertStreamToString(InputStream inputStream); static Result<String, IOException> convertStreamToString(InputStream inputStream, Charset encoding); static void close(@Nullable Closeable closeable); static void close(@Nullable Closeable closeable, @Nullable Consumer<IOException> exceptionConsumer); static final int DEFAULT_BUFFER_SIZE; }