Package java.io

Examples of java.io.PipedInputStream


  }

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

  public void put (String sFile) throws IOException {
    oInPipe = new PipedInputStream();
    sPar1 = sFile;
    iCmd = PUT_PIPE;
  } // put()
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);
View Full Code Here

            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

            MsgUnitRaw msg = new MsgUnitRaw(null, content, qos);
            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];
View Full Code Here

 
    final DataSource ds = processor.getDataOutput();

    final DataSink[] streamDataSinkHolder = new DataSink[] {null};
    // connect the data output of the processor to a StreamDataSink, which will make the data available to PipedInputStream, which we return.
    final PipedInputStream in = new PipedInputStream() {

      // override close to clean up everything when the media has been served.
      @Override
      public void close() throws IOException
      {
View Full Code Here

        .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();
    mctx.setOutput(new PrintWriter(pos));
View Full Code Here

        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);
View Full Code Here

        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);
View Full Code Here

        int readNow;
        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 {
View Full Code Here

            /* 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);
View Full Code Here

TOP

Related Classes of java.io.PipedInputStream

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.