TeeInputStream tee = new TeeInputStream(is, new PipedOutputStream(in));
TeeInputStream tee = new TeeInputStream(is, new PipedOutputStream(in));
... BufferedInputStream bis = new BufferedInputStream(is); TeeInputStream tis = new TeeInputStream(bis,new FileOutputStream("test.mp3")); BasicPlayer player = new BasicPlayer(); player.open(tis); player.play();
// http://stackoverflow.com/a/12107486/82156 public static InputStream wrapInputStreamAndCopyToOutputStream(InputStream in, final boolean gzipped, final OutputStream out) throws IOException { // Create a tee-splitter for the other reader. final PipedInputStream inCopy = new PipedInputStream(); final TeeInputStream inWrapper = new TeeInputStream(in, new PipedOutputStream(inCopy)); new Thread(Thread.currentThread().getName() + "-log-writer") { @Override public void run() { try { IOUtils.copy(gzipped ? new GZIPInputStream(inCopy) : inCopy, new BufferedOutputStream(out)); } catch (IOException e) { Log.e(TAG, e); } } }.start(); return inWrapper; }
InputStream inStream = new FileInputStream(fileName); PipedInputStream pipedInStream = new PipedInputStream(); OutputStream pipedOutStream = new PipedOutputStream(pipedInStream); TeeInputStream tin = new TeeInputStream(inStream, pipedOutStream); ReaderThread firstThread = new ReaderThread(1,tin); ReaderThread secondThread = new ReaderThread(2,pipedInStream); firstThread.start(); secondThread.start();
final TeeInputStream tee1 = new TeeInputStream(is1, pos1, true); final TeeInputStream tee2 = new TeeInputStream(is2, pos2, true);
@Override public SOAPMessage createMessage(MimeHeaders headers, InputStream in) throws SOAPException, IOException { String contentTypeString = MessageImpl.getContentType(headers); if (listener != null) { in = new TeeInputStream(in, listener); } try { ContentType contentType = new ContentType(contentTypeString); int stat = MessageImpl.identifyContentType(contentType); if (MessageImpl.isSoap1_1Content(stat)) { return new Message1_1Impl(headers,contentType,stat,in); } else if (MessageImpl.isSoap1_2Content(stat)) { return new Message1_2Impl(headers,contentType,stat,in); } else { log.severe("SAAJ0530.soap.unknown.Content-Type"); throw new SOAPExceptionImpl("Unrecognized Content-Type"); } } catch (ParseException e) { log.severe("SAAJ0531.soap.cannot.parse.Content-Type"); throw new SOAPExceptionImpl( "Unable to parse content type: " + e.getMessage()); } }