Package java.io

Examples of java.io.BufferedInputStream.mark()


            InputStream in = httpRequest.getInputStream();
            if (in != null) {
                // use a buffered input stream to find out whether there actually
                // is a request body
                InputStream bin = new BufferedInputStream(in);
                bin.mark(1);
                boolean isEmpty = -1 == bin.read();
                bin.reset();
                if (!isEmpty) {
                    DocumentBuilder docBuilder = DomUtil.BUILDER_FACTORY.newDocumentBuilder();
                    requestDocument = docBuilder.parse(bin);
View Full Code Here


    snapshot = FileSnapshot.save(liveFile);

    // After the file entries are index extensions, and then a footer.
    //
    for (;;) {
      in.mark(21);
      IO.readFully(in, hdr, 0, 20);
      if (in.read() < 0) {
        // No extensions present; the file ended where we expected.
        //
        break;
View Full Code Here

        DataObject unmaThingy = new DataObject();
        unmaThingy.type = stream.readChar();
        unmaThingy.time = stream.readLong();
       
        assertTrue( "Mark/reset is not supported", bis.markSupported() );
        bis.mark(8);
        int [] intBytes = new int [4];
        intBytes[0] = bis.read();
        intBytes[1] = bis.read();
        intBytes[2] = bis.read();
        intBytes[3] = bis.read();
View Full Code Here

  public ByteBuffer loadImage(InputStream is, boolean flipped, boolean forceAlpha, int[] transparent) throws IOException {
    CompositeIOException exception = new CompositeIOException();
    ByteBuffer buffer = null;
   
    BufferedInputStream in = new BufferedInputStream(is, is.available());
    in.mark(is.available());
   
    // cycle through our source until one of them works
    for (int i=0;i<sources.size();i++) {
      in.reset();
      try {
View Full Code Here

    private DocumentReport getTagSoupDOM(ExtractionParameters extractionParameters)
    throws IOException, ValidatorException {
        if (documentReport == null || !extractionParameters.equals(tagSoupDOMRelatedParameters)) {
            ensureHasLocalCopy();
            final InputStream is = new BufferedInputStream( localDocumentSource.openInputStream() );
            is.mark(Integer.MAX_VALUE);
            final String candidateEncoding = getParserEncoding();
            is.reset();
            final TagSoupParser tagSoupParser = new TagSoupParser(
                    is,
                    documentURI.stringValue(),
View Full Code Here

   
    BufferedReader reader(HttpServletRequest httpRequest)
        throws IOException {
        //create a buffer so we can reset the input stream
        BufferedInputStream input = new BufferedInputStream(httpRequest.getInputStream());
        input.mark(XML_LOOKAHEAD);

        //create object to hold encoding info
        EncodingInfo encoding = new EncodingInfo();

        //call this method to set the encoding info
View Full Code Here

              } catch (Exception e1) {
                // Fall back to the format used by EJBCA WS RA CLI stress test
                System.out.println("Parsing as textfile failed ("+e1.getMessage()+"). Trying to use it as a file with Java Objects.");
                vSerialNrsTmp = new ArrayList<BigInteger>();
                    InputStream is = new BufferedInputStream(new FileInputStream(fileName));
                    is.mark(1);
                    try {
                        ObjectInput oi = null;
                        while( true ) {
                            for ( int i=100; oi==null && i>0; i--) {
                                is.reset();
View Full Code Here

                        ObjectInput oi = null;
                        while( true ) {
                            for ( int i=100; oi==null && i>0; i--) {
                                is.reset();
                                try {
                                    is.mark(i);
                                    oi = new ObjectInputStream(is);
                                } catch( StreamCorruptedException e) {
                                    is.reset();
                                    is.read();
                                }
View Full Code Here

                            }
                            if ( oi==null ) {
                                break;
                            }
                            try {
                                is.mark(100);
                                vSerialNrsTmp.add((BigInteger)oi.readObject());
                            } catch( StreamCorruptedException e ) {
                                oi=null;
                            }
                        }
View Full Code Here

    private HeaderParser() {
    }

    public static InputStream wireTapManifest( InputStream is, Manifest mf ) throws IOException {
        BufferedInputStream bis = new BufferedInputStream( is, 64 * 1024 );
        bis.mark( 64 * 1024 );
        JarInputStream jis = new JarInputStream( bis );
        mf.getMainAttributes().putAll( jis.getManifest().getMainAttributes() );
        mf.getEntries().putAll( jis.getManifest().getEntries() );
        bis.reset();
        return bis;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.