Package java.io

Examples of java.io.InputStream.mark()


                            mimeType = mimeType + "; charset=UTF-8";
                        } else {
                            // detect charset of html-files
                            if((path.endsWith("html") || path.endsWith("htm"))) {
                                // save position
                                fis.mark(1000);
                                // scrape document to look up charset
                                final ScraperInputStream htmlFilter = new ScraperInputStream(fis,"UTF-8",new DigestURI("http://localhost"),null,false);
                                final String charset = htmlParser.patchCharsetEncoding(htmlFilter.detectCharset());
                                if(charset != null)
                                    mimeType = mimeType + "; charset="+charset;
View Full Code Here


                response.commit();

                if (response.getKeepAlive()) {
                    InputStream is = request.getRawInputStream();
                    if (is != null && is.markSupported()) {
                        is.mark(4);
                        if (is.read() != '\r' || is.read() != '\n')
                            is.reset();
                    }
                } else
                    break;
View Full Code Here

            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) {
                    requestDocument = DomUtil.parseDocument(bin);
                }
View Full Code Here

        } catch (RuntimeException e) {
            LOGGER.error(e.getMessage());
            throw e;
        }
        try {
            is.mark(256 * 1024);
            JarInputStream jar = new JarInputStream(is);
            Manifest m = jar.getManifest();
            if(m == null) {
                throw new BundleException("Manifest not present in the first entry of the zip " + bundleLocation);
            }
View Full Code Here

        byte[] dst = new byte[src.length];
        ByteBuffer bb = ByteBuffer.wrap(src);
        InputStream is = new ByteBufferInputStream(bb);

        assertEquals(true, is.markSupported());
        is.mark(src.length);
        assertEquals(dst.length, is.read(dst));
        assertArrayEquals(src, dst);
        assertEquals(-1, is.read());
        is.close();
View Full Code Here

            rewindStream((InputStream)in, hdrLen);
        } else {
            final InputStream srcIn = (InputStream)in;
            final boolean markSet = srcIn.markSupported();
            if (markSet) {
                srcIn.mark(MAX_STREAM_HEADER_LENGTH);
            }
            byte[] header = new byte[MAX_STREAM_HEADER_LENGTH];
            int read = in.read(header);
            // Expect at least two header bytes.
            if (SanityManager.DEBUG) {
View Full Code Here

    final LZ4FastDecompressor decompressor = LZ4Factory.fastestInstance().fastDecompressor();
    InputStream is = new LZ4BlockInputStream(open(compressed.toByteArray()), decompressor, checksum);
    assertFalse(is.markSupported());
    try {
      is.mark(1);
      is.reset();
      assertFalse(true);
    } catch (IOException e) {
      // OK
    }
View Full Code Here

        long nextPos = 0;
        String chunkOfLastLine = null;
        int attemptCount = 0;
        String s = "";
        while (attemptCount < MAX_ATTEMPT_COUNT) {
            in.mark(FOUR_KB + (int) nextPos);
            if (nextPos > 0) {
                long skipped = in.skip(nextPos);
                if (skipped != nextPos) {
                    break;
                }
View Full Code Here

      int bytesRead=-1
      int size = stateSize;
      try {                             
        while(size>0)
        {
          stream.mark(markSize);
          bytesRead=stream.read(buffer);
          ostream.write(buffer);
          stream.reset();                 
          size = size-bytesRead;         
        }         
View Full Code Here

            int start = 0;
            for (int i = 0; i < fragment.length; i++) {
                int offset = start;
                int length = fragment[i] - offset;
                InputStream in = new ByteArrayInputStream(bytes, offset, bytes.length - offset);
                in.mark(bytes.length - offset);
                ModelInput<Object> reader = unsafe.createInput(model.unwrap().getClass(), "hello", in,
                        offset, length);
                try {
                    while (true) {
                        Object buffer = loaded.newModel("Tuple").unwrap();
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.