/** @deprecated Use {@link InputStreams#wye(InputStream, OutputStream)} instead*/ @Deprecated public static InputStream wye(InputStream in, final OutputStream out) { return InputStreams.wye(in, out); }
/** @deprecated Use {@link InputStreams#onEndOfInput(InputStream, Runnable)} instead */ @Deprecated public static InputStream onEndOfInput(InputStream delegate, final Runnable runnable) { return InputStreams.onEndOfInput(delegate, runnable); }
/** @deprecated Use {@link InputStreams#skip(InputStream, long)} instead */ @Deprecated public static long skip(InputStream inputStream, long n) throws IOException { return InputStreams.skip(inputStream, n); }
in = InputStreams.wye(in, OutputStreams.lengthWritten(ConsumerUtil.cumulate(rawByteCount, 0))); in = InputStreams.wye(in, ( this.contentTypeIsXmlish() ? new WriterOutputStream(new XMLFormatterWriter(lw)) in = InputStreams.wye(in, OutputStreams.lengthWritten(ConsumerUtil.cumulate(decodedByteCount, 0))); in = InputStreams.onEndOfInput(in, new Runnable() {
@Override public void dispose() { InputStream in3 = this.in2; if (in3 != null) { try { InputStreams.skipAll(in3); } catch (Exception e) {} try { in3.close(); } catch (Exception e) {} } this.in2 = null; } };
/** @deprecated Use {@link InputStreams#unclosable(InputStream)} instead */ @Deprecated public static InputStream unclosableInputStream(InputStream delegate) { return InputStreams.unclosable(delegate); }
/** @deprecated Use {@link InputStreams#byteProducerInputStream(Producer)} instead */ @Deprecated public static InputStream byteProducerInputStream(final Producer<? extends Byte> delegate) { return InputStreams.byteProducerInputStream(delegate); }
/** @deprecated Use {@link InputStreams#constantInputStream(byte)} instead */ @Deprecated public static InputStream constantInputStream(final byte b) { return InputStreams.constantInputStream(b); }
@Override public void dispose() { InputStream is = this.is; if (is != null) { try { InputStreams.skipAll(is); } catch (Exception e) {} try { is.close(); } catch (Exception e) {} } this.is = null; } };
/** * @param <T> {@link #handleNormalContents(InputStream)} returns a value of this type, * which is, in turn, returned by the {@code processStream()} and {@code * processValue()} methods * @see #handleNormalContents(InputStream) */ public interface NormalContentsHandler<T> { /** * May or may not read from the <var>inputStream</var>, and may or may not close it. * * @see #processFile(File, Predicate, ArchiveHandler, Predicate, CompressorHandler, NormalContentsHandler) * @see CompressUtil#processStream(InputStream, Predicate, ArchiveHandler, Predicate, CompressorHandler, * NormalContentsHandler) */ @Nullable T handleNormalContents(InputStream inputStream) throws IOException; }
/** @deprecated Use {@link InputStreams#byteProducerInputStream(ProducerWhichThrows)} instead */ @Deprecated public static InputStream byteProducerInputStream(final ProducerWhichThrows<? extends Byte, ? extends IOException> delegate) { return InputStreams.byteProducerInputStream(delegate); }
/** * Consumes the <var>inputStream</var>, feeds it through the <var>contentsTransformer</var>, and checks whether * the output is identical with the input. * * @throws RuntimeException {@link FileTransformer#NOT_IDENTICAL} iff the transformer contents differs from the * original contents */ public static void checkIdentity( String path, InputStream inputStream, ContentsTransformer contentsTransformer, boolean closeInputStream ) throws IOException { try { OutputStream[] oss = OutputStreams.compareOutput(2, RunnableUtil.NOP, FileTransformer.THROW_NOT_IDENTICAL); contentsTransformer.transform(path, InputStreams.wye(inputStream, oss[0]), oss[1]); oss[0].close(); oss[1].close(); if (closeInputStream) inputStream.close(); } finally { if (closeInputStream) try { inputStream.close(); } catch (Exception e) {} } } }
/** @deprecated Use {@link InputStreams#skipAll(InputStream)} instead */ @Deprecated public static long skipAll(InputStream inputStream) throws IOException { return InputStreams.skipAll(inputStream); }
if (InputStreams.skip(is, from) != from) { throw new IOException("Cannot skip " + from + " bytes of \"" + file + "\"");
/** * @return An input stream which reads and endless stream of random bytes */ public static InputStream randomInputStream(final long seed) { return InputStreams.byteProducerInputStream(ProducerUtil.randomByteProducer(seed)); }
/** * Connects to the given <var>address</var> and <var>port</var>. Data can be sent to the remote server through the * {@link OutputStream} returned by {@link #getOutputStream()}, and data can be read from the remote server * through the {@link InputStream} returned by {@link #getInputStream()}. */ public TcpClient(InetAddress address, int port) throws IOException { this.socket = new Socket(address, port); LOGGER.fine("Connected to " + this.socket.getRemoteSocketAddress()); InputStream in = this.socket.getInputStream(); OutputStream out = this.socket.getOutputStream(); boolean logData = LOGGER.isLoggable(FINEST); this.fromServer = ( logData ? InputStreams.wye(in, new HexOutputStream(LogUtil.logWriter(LOGGER, FINEST, "<From Server< "))) : in ); this.toServer = ( logData ? OutputStreams.tee(out, new HexOutputStream(LogUtil.logWriter(LOGGER, FINEST, ">To Server> "))) : out ); }
/** * @return An input stream which reads the data produced by the <var>delegate</var> byte producer; {@code null} * products are returned as 'end-of-input' */ public static InputStream byteProducerInputStream(final Producer<? extends Byte> delegate) { return InputStreams.byteProducerInputStream(ProducerUtil.<Byte, IOException>asProducerWhichThrows(delegate)); }
return is; } else { return InputStreams.wye(is, OutputStreams.lengthWritten(new Consumer<Integer>() {
@Override public void run() throws IOException { InputStream in = new ByteArrayInputStream(buffer.toByteArray()); // Process "Content-Encoding" header. if ("gzip".equalsIgnoreCase(HttpMessage.this.getHeader("Content-Encoding"))) { LOGGER.fine(loggingPrefix + "GZIP-encoded content"); in = new GZIPInputStream(in); } if (LOGGER.isLoggable(FINE)) { LOGGER.fine(loggingPrefix + "Reading message body"); Writer lw = LogUtil.logWriter(LOGGER, FINE, loggingPrefix); in = InputStreams.wye(in, ( HttpMessage.this.contentTypeIsXmlish() ? new WriterOutputStream(new XMLFormatterWriter(lw)) : new HexOutputStream(lw) )); } HttpMessage.this.setBody(HttpMessage.body(in)); finished.run(); } };
in = InputStreams.wye( in, new HexOutputStream(LogUtil.logWriter(LOGGER, FINEST, "<From Client< "))