/** @deprecated Use {@link InputStreams#wye(InputStream, OutputStream)} instead*/ @Deprecated public static InputStream wye(InputStream in, final OutputStream out) { return InputStreams.wye(in, out); }
/** * 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) {} } } }
/** * 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 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< "))
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.wye(in, OutputStreams.lengthWritten(ConsumerUtil.cumulate(requestSize, 0)));