final @WillClose OutputStream out) throws IOException { Streams.copy(in, out);
void cat1(String name) throws IOException { // START SNIPPET: cat1 Path path = new TPath(name); InputStream in = Files.newInputStream(path); try { Streams.cat(in, System.out); } finally { in.close(); // ALWAYS close the stream! } // END SNIPPET: cat1 }
private void assertCopy(final ByteArrayIOBuffer buffer) throws IOException { final byte[] data = buffer.getData(); final TestInputStream in = newTestInputStream(buffer); final TestOutputStream out = newTestOutputStream(buffer); Thread.currentThread().interrupt(); Streams.copy(in, out); assertTrue(Thread.interrupted()); // test and clear status! assertTrue(out.flushed); assertTrue(out.closed); assertTrue(in.closed); assertNotSame(data, buffer.getData()); assertArrayEquals(data, buffer.getData()); }
void cat2(String name) { // START SNIPPET: cat2 try { Path path = new TPath(name); InputStream in = Files.newInputStream(path); try { Streams.cat(in, System.out); } finally { in.close(); // ALWAYS close the stream! } } catch (IOException ouch) { ouch.printStackTrace(); } // END SNIPPET: cat2 }
final @WillNotClose OutputStream out) throws IOException { Streams.cat(in, out);
Streams.cat(in, out); } finally { in.close();
final @WillClose TFileOutputStream out = new TFileOutputStream(this); try { Streams.cat(in, out); } finally { out.close();
Streams.cat(new ByteArrayInputStream(getData()), out); } finally { out.close(); Streams.cat(new ByteArrayInputStream(getData()), out); } finally { out.close(); Streams.cat(new ByteArrayInputStream(getData()), out); Streams.cat(new ByteArrayInputStream(getData()), out); // write again Streams.cat(new ByteArrayInputStream(getData()), out); // write again fail(); } catch (OutputClosedException ex) {
@Override void cat(final TestInputStream in, final TestOutputStream out) throws IOException { final ThrowControl control = TestConfig.get().getThrowControl(); control.trigger(ThrowingOutputStream.class, expected); final ThrowingOutputStream tos = new ThrowingOutputStream(out); Streams.cat(in, out); try { Streams.cat(in, tos); fail(); } catch (final IOException got) { if (!contains(got, expected)) throw got; } catch (final RuntimeException got) { if (!contains(got, expected)) throw got; } catch (final Error got) { if (!contains(got, expected)) throw got; } } }.run();
@Override void cat(final TestInputStream in, final TestOutputStream out) throws IOException { final ThrowControl control = TestConfig.get().getThrowControl(); control.trigger(ThrowingInputStream.class, expected); final ThrowingInputStream tis = new ThrowingInputStream(in, control); try { Streams.cat(tis, out); fail(); } catch (final IOException got) { if (!contains(got, expected)) throw got; } catch (final RuntimeException got) { if (!contains(got, expected)) throw got; } catch (final Error got) { if (!contains(got, expected)) throw got; } Streams.cat(in, out); } }.run();
write(new byte[4 - (int) (ol % 4)]); Streams.cat(in, this); } catch (final IOException ex2) { ex = ex2;
zos.putNextEntry(local); try { Streams.cat(in, zos); } catch (final InputException ex) { // NOT IOException! builder.warn(ex);
Streams.cat(in, System.out); // copy the data } finally {