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 }
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();
final InputStream in = source.getPreambleInputStream(); try { Streams.cat(in, source.offsetsConsiderPreamble() ? this : out); } finally {
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 {