Package java.io

Examples of java.io.SequenceInputStream


        InputStream input = getInstance(fileName).openFileInputStream(fileName);
        for (int i = 1;; i++) {
            String f = getFileName(fileName, i);
            if (getInstance(f).exists(f)) {
                InputStream i2 = getInstance(f).openFileInputStream(f);
                input = new SequenceInputStream(input, i2);
            } else {
                break;
            }
        }
        return input;
View Full Code Here


     */
    private void readTrailer() throws IOException {
  InputStream in = this.in;
  int n = inf.getRemaining();
  if (n > 0) {
      in = new SequenceInputStream(
      new ByteArrayInputStream(buf, len - n, n), in);
  }
  // Uses left-to-right evaluation order
  if ((readUInt(in) != crc.getValue()) ||
      // rfc1952; ISIZE is the input size modulo 2^32
View Full Code Here

   }

   protected InputStream addHeaderToHeadlessStream(InputStream is)
           throws UnsupportedEncodingException
   {
      return new SequenceInputStream(createHeaderInputStream(), is);
   }
View Full Code Here

      {
         InputStream bis = new ByteArrayInputStream(byteBuffer, byteBufferOffset, byteBufferLength);
         if (tempFile == null)
            return bis;
         InputStream fis = new FileInputStream(tempFile);
         return new SequenceInputStream(bis, fis);
      }
View Full Code Here

            //it is possible that two operators will get concatenated
            //together
            inputStreams.add( new ByteArrayInputStream( inbetweenStreamBytes ) );
        }

        return new SequenceInputStream( inputStreams.elements() );
    }
View Full Code Here

                public InputStream nextElement() {
                    return streams[index++];
               
               
            };
            return new SequenceInputStream(list);
        } else {
            return is;
        }
                
    }
View Full Code Here

            //only copy up to the limit since that's all we need to log
            //we can stream the rest
            IOUtils.copyAtLeast(bis, bos, limit);
            bos.flush();
            bis = new SequenceInputStream(bos.getInputStream(), bis);
           
            // restore the delegating input stream or the input stream
            if (is instanceof DelegatingInputStream) {
                ((DelegatingInputStream)is).setInputStream(bis);
            } else {
View Full Code Here

        v.add(new ByteArrayInputStream("<a>".getBytes("ascii")));
        v.add(ds.getInputStream());
        v.add(new ByteArrayInputStream("</a>".getBytes("ascii")));
        OMElement element = OMXMLBuilderFactory.createOMBuilder(factory,
                StAXParserConfiguration.NON_COALESCING,
                new SequenceInputStream(v.elements()), "ascii").getDocumentElement();
        Reader in = element.getTextAsStream(false);
        IOTestUtils.compareStreams(new InputStreamReader(ds.getInputStream(), "ascii"), in);
    }
View Full Code Here

          in.reset();
          parseWritable(in);
        } else {
          // We cannot use BufferedInputStream, it consumes more than we read from the underlying IS
          ByteArrayInputStream bais = new ByteArrayInputStream(pbuf);
          SequenceInputStream sis = new SequenceInputStream(bais, in); // Concatenate input streams
          // TODO: Am I leaking anything here wrapping the passed in stream?  We are not calling close on the wrapped
          // streams but they should be let go after we leave this context?  I see that we keep a reference to the
          // passed in inputstream but since we no longer have a reference to this after we leave, we should be ok.
          parseWritable(new DataInputStream(sis));
        }
View Full Code Here

     */
    private File mergeChunks(final Node parentNode,
            final InputStream lastChunkStream) throws PersistenceException,
            RepositoryException {
        OutputStream out = null;
        SequenceInputStream  mergeStrm = null;
        File file = null;
        try {
            file = File.createTempFile("tmp-", "-mergechunk");
            out = new FileOutputStream(file);
            String startPattern = SlingPostConstants.CHUNK_NODE_NAME + "_"
                + "0_*";
            NodeIterator nodeItr = parentNode.getNodes(startPattern);
            InputStream ins = null;
            int i = 0;
            Set<InputStream> inpStrmSet = new LinkedHashSet<InputStream>();
            while (nodeItr.hasNext()) {
                if (nodeItr.getSize() > 1) {
                    throw new RepositoryException(
                        "more than one node found for pattern: " + startPattern);
                }
                Node rangeNode = nodeItr.nextNode();

                inpStrmSet.add(rangeNode.getProperty(
                    javax.jcr.Property.JCR_DATA).getBinary().getStream());
                log.debug("added chunk {} to merge stream", rangeNode.getName());
                String[] indexBounds = rangeNode.getName().substring(
                    (SlingPostConstants.CHUNK_NODE_NAME + "_").length()).split(
                    "_");
                startPattern = SlingPostConstants.CHUNK_NODE_NAME + "_"
                    + String.valueOf(Long.valueOf(indexBounds[1]) + 1) + "_*";
                nodeItr = parentNode.getNodes(startPattern);
            }

            inpStrmSet.add(lastChunkStream);
            mergeStrm = new SequenceInputStream(
                Collections.enumeration(inpStrmSet));
            IOUtils.copyLarge(mergeStrm, out);
        } catch (IOException e) {
            throw new PersistenceException("excepiton occured", e);
        } finally {
View Full Code Here

TOP

Related Classes of java.io.SequenceInputStream

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.