Package java.io

Examples of java.io.PipedOutputStream


  } // put()

  //-----------------------------------------------------------

  public void move (String sFile) throws IOException {
    oOutPipe = new PipedOutputStream();
    sPar1 = sFile;
    iCmd = MOV_PIPE;
  }
View Full Code Here


  private void parse(StreamSource source, String baseURI)
    throws IOException, RDFParseException, RDFHandlerException
  {
    CountDownLatch latch = new CountDownLatch(1);
    PipedInputStream pipe = new PipedInputStream();
    PipedOutputStream out = new PipedOutputStream(pipe);

    try {
      parse(pipe, baseURI, latch);

      transformer.transform(source, new StreamResult(out));
    }
    catch (TransformerException e) {
      handleException();
      throw new RDFParseException(e);
    }
    finally {
      out.close();
    }

    await(latch);
  }
View Full Code Here

               this.timestamp = this.timer.addTimeoutListener(this, this.waitForChunksTimeout, null);
            try {
               if (isFirstChunk(updQos)) {
                  this.mutex.acquire();
                  this.cbSessionId = cbSessId;
                  this.out = new PipedOutputStream();
                  this.in = new PipedInputStream(this.out);
                  ExecutionThread thread = new ExecutionThread(cbSessId, updKey, cont, updQos);
                  thread.start();
               }
               else { // check if the message is complete
View Full Code Here

            msgInfo.addMessage(msg);
            byte[] raw = parser.createRawMsg(msgInfo);
            System.out.println(parser.toLiteral(raw));

            PipedInputStream in = new PipedInputStream();
            PipedOutputStream out = new PipedOutputStream(in);
            out.write(raw);
            out.flush();
            out.close();
            MsgInfo msgInfoNew = parser.parse(in)[0];
            byte[] rawNew = parser.createRawMsg(msgInfoNew);
            System.out.println("Parsed and dumped again:" + parser.toLiteral(rawNew));
         }
         {
            System.out.println("TEST1 SHOULD FORCE BASE64");
            parser.init(glob, null, null);
            MsgInfo msgInfo = new MsgInfo(glob, MsgInfo.INVOKE_BYTE, "12",
                  MethodName.PUBLISH, "secret", null);
            byte[] content = "hello&bye]]>".getBytes();
            //content[3] = 0;
            MsgUnitRaw msg = new MsgUnitRaw("<key oid='hello'/>", content, "<qos></qos>");
            msgInfo.addMessage(msg);
            byte[] raw = parser.createRawMsg(msgInfo);
            System.out.println("Initial creation:" + parser.toLiteral(raw));

            PipedInputStream in = new PipedInputStream();
            PipedOutputStream out = new PipedOutputStream(in);
            out.write(raw);
            out.flush();
            out.close();
            MsgInfo msgInfoNew = parser.parse(in)[0];
            byte[] rawNew = parser.createRawMsg(msgInfoNew);
            System.out.println("Parsed and dumped again:" + parser.toLiteral(rawNew));
         }
         {
            System.out.println("TEST2 SHOULD KEEP LITERAL STRING");
            parser.init(glob, null, null);
            MsgInfo msgInfo = new MsgInfo(glob, MsgInfo.INVOKE_BYTE, "12",
                  MethodName.PUBLISH, "secret", null);
            byte[] content = "Hello World!".getBytes();
            MsgUnitRaw msg = new MsgUnitRaw("<key oid='hello'/>", content, "<qos></qos>");
            msgInfo.addMessage(msg);
            byte[] raw = parser.createRawMsg(msgInfo);
            System.out.println("Initial creation:" + parser.toLiteral(raw));

            PipedInputStream in = new PipedInputStream();
            PipedOutputStream out = new PipedOutputStream(in);
            out.write(raw);
            out.flush();
            out.close();
            MsgInfo msgInfoNew = parser.parse(in)[0];
            byte[] rawNew = parser.createRawMsg(msgInfoNew);
            System.out.println("Parsed and dumped again:" + parser.toLiteral(rawNew));
         }
         {
View Full Code Here

          streamDataSinkHolder[0].close();
        }
      }
     
    };
    final PipedOutputStream out = new PipedOutputStream(in);
    final DataSink streamDataSink = new StreamDataSink(out);
    streamDataSinkHolder[0] = streamDataSink;
   
    streamDataSink.setSource(ds);
    streamDataSink.open();
View Full Code Here

   
    try
    {

      pipedInputStream = new BigPipedInputStream(PIPE_SIZE);
      pipedOutputStream = new PipedOutputStream(pipedInputStream);

    }
    catch (IOException e)
    {  throw new RuntimeException(e);
    }
View Full Code Here

    StyledLayerDescriptorInfo sld = (StyledLayerDescriptorInfo) uctx.unmarshalDocument(getClass()
        .getResourceAsStream("samples/example-sld.xml"), null);

    // pipe to geotools parser
    StyleFactory factory = CommonFactoryFinder.getStyleFactory(null);
    PipedOutputStream pos = new PipedOutputStream();
    PipedInputStream pii = new PipedInputStream(pos);

    final SLDParser parser = new SLDParser(factory, pii);

    IMarshallingContext mctx = bfact.createMarshallingContext();
View Full Code Here

        HttpServer server = new HttpServer(new EchoHandler());
        server.start();
       
        HttpClient httpClient = new HttpClient();

        PipedOutputStream pos = new PipedOutputStream();
        PipedInputStream pis = new PipedInputStream(pos);

        pos.write("Hello ".getBytes());
       
        FutureResponseHandler respHdl = new FutureResponseHandler();
        httpClient.send(new HttpRequest(new HttpRequestHeader("POST", "http://localhost:" + server.getLocalPort() + "/", "text/plain"), pis), respHdl);
       
        IHttpResponse response = respHdl.getResponse();
       
        QAUtil.sleep(300);
        pos.write("how ".getBytes());
       
        QAUtil.sleep(300);
        pos.write("are ".getBytes());

        QAUtil.sleep(300);
        pos.write("you".getBytes());
        pos.close();
       
        QAUtil.sleep(1000);
       
       
        Assert.assertEquals(200, response.getStatus());
View Full Code Here

        int readBlocks = (int) (dataSize / 512L);
        int modulus    = (int) (dataSize % 512L);

        // Couldn't care less about the entry "name" field.
        PipedInputStream  inPipe  = null;
        PipedOutputStream outPipe = new PipedOutputStream();

        /* This constructor not available until Java 1.6:
                new PipedInputStream(outPipe, (int) dataSize);
        */
        try {
            inPipe = new PipedInputStream(outPipe);
            while (readBlocks > 0) {
                readNow = (readBlocks > archive.getReadBufferBlocks())
                          ? archive.getReadBufferBlocks()
                          : readBlocks;

                archive.readBlocks(readNow);

                readBlocks -= readNow;

                outPipe.write(archive.readBuffer, 0, readNow * 512);
            }

            if (modulus != 0) { archive.readBlock();
                outPipe.write(archive.readBuffer, 0, modulus);
            }

            outPipe.flush();    // Do any good on a pipe?
        } catch (IOException ioe) {
            if (inPipe != null) {
                inPipe.close();
            }

            throw ioe;
        } finally {
            try {
                outPipe.close();
            } finally {
                outPipe = null// Encourage buffer GC
                inPipe = null// Encourage buffer GC
            }
        }
View Full Code Here

            if (maxBytes < 1) {
                throw new IllegalArgumentException(RB.read_lt_1.getString());
            }

            int               i;
            PipedOutputStream outPipe = new PipedOutputStream();

            /* This constructor not available until Java 1.6:
            inputStream = new PipedInputStream(outPipe, maxBytes);
            */
            try {
                inputStream = new PipedInputStream(outPipe);
                while ((i =
                        origStream
                            .read(tarStream.writeBuffer, 0, tarStream
                                .writeBuffer.length)) > 0) {
                    outPipe.write(tarStream.writeBuffer, 0, i);
                }

                outPipe.flush();    // Do any good on a pipe?

                dataSize = inputStream.available();

                if (TarFileOutputStream.debug) {
                    System.out.println(
                        RB.stream_buffer_report.getString(
                                Long.toString(dataSize)));
                }
            } catch (IOException ioe) {
                close();

                throw ioe;
            } finally {
                try {
                    outPipe.close();
                } finally {
                    outPipe = null// Encourage buffer GC
                }
            }

View Full Code Here

TOP

Related Classes of java.io.PipedOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.