Examples of mark()


Examples of java.io.ByteArrayInputStream.mark()

            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

Examples of java.io.DataInputStream.mark()

        out.close();
        DataInputStream in = new DataInputStream(tmp.getInputStream());
        byte[] data1 = new byte[sourceData1.length];
        byte[] data2 = new byte[sourceData2.length];
        in.readFully(data1);
        in.mark(sourceData2.length);
        in.readFully(data2);
        in.reset();
        in.readFully(data2);
        assertTrue(Arrays.equals(sourceData1, data1));
        assertTrue(Arrays.equals(sourceData2, data2));
View Full Code Here

Examples of java.io.FileInputStream.mark()

                    || "gzip".equals(contentEncoding)
                    || "x-gzip".equals(contentEncoding)) {               
                return new GZIPInputStream(new FileInputStream(file));
            } else if (fileName.endsWith(".bz2")) {
                InputStream is = new FileInputStream(file);
                is.mark(4);
                if (!(is.read() == 'B' && is.read() == 'Z')) {
                    // No BZ prefix as appended by command line tools.  Reset and hope for the best
                    is.reset();
                }
                return new CBZip2InputStream(is);
View Full Code Here

Examples of java.io.FilterInputStream.mark()

                    return 0;
                }
                return in.read(buffer, off, Math.min(10, max));
            }
        };
        in.mark(10000);
        byte[] test = new byte[1000];

        // readFully is not supposed to call read when reading 0 bytes
        assertEquals(0, IOUtils.readFully(in, test, 0, 0));
        assertEquals(0, readCount.get());
View Full Code Here

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

Examples of java.io.InputStream.mark()

        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

Examples of java.io.InputStream.mark()

      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

Examples of java.io.PushbackInputStream.mark()

  }

  public void test_mark() {
    PushbackInputStream pb = new PushbackInputStream(
        new ByteArrayInputStream(new byte[] { 0 }), 2);
    pb.mark(Integer.MAX_VALUE);
    pb.mark(0);
    pb.mark(-1);
    pb.mark(Integer.MIN_VALUE);
  }
View Full Code Here

Examples of java.io.Reader.mark()

  public void testMarkAndReset() throws IOException
  {
    Reader data = new StringReader(DATA);
    Reader reader = new LimitReader(data, 10);
    char[] buf = new char[5];
    reader.mark(100);
    reader.read(buf);
    assertArrayEquals("Hello".toCharArray(), buf);
    reader.reset();
    reader.read(buf);
    assertArrayEquals("Hello".toCharArray(), buf);
View Full Code Here

Examples of java.io.StringReader.mark()

            try {
                reader = new StringReader(headerValue);
                // get the first character to decide - expect '(' or '<'
                try {
                    reader.mark(1);
                    firstChar = readWhiteSpace(reader);
                    reader.reset();
                } catch (IOException ignore) {
                    // may be thrown according to API but is only thrown by the
                    // StringReader class if the reader is already closed.
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.