Package java.io

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


  @Test
  public void testSkipFully() throws IOException {
    byte inArray[] = new byte[] {0, 1, 2, 3, 4};
    ByteArrayInputStream in = new ByteArrayInputStream(inArray);
    try {
      in.mark(inArray.length);
      IOUtils.skipFully(in, 2);
      IOUtils.skipFully(in, 2);
      try {
        IOUtils.skipFully(in, 2);
        fail("expected to get a PrematureEOFException");
View Full Code Here

    try {
            ByteArrayInputStream is = (ByteArrayInputStream) super
                    .getInputStream(manifestEntry);
            if (verifier != null) {
                byte[] buf = new byte[is.available()];
                is.mark(buf.length);
                is.read(buf, 0, buf.length);
                is.reset();
                verifier.addMetaEntry(manifestEntry.getName(), buf);
            }
            try {
View Full Code Here

        try {
            ByteArrayInputStream is = (ByteArrayInputStream) super
                    .getInputStream(manifestEntry);
            if (verifier != null) {
                byte[] buf = new byte[is.available()];
                is.mark(buf.length);
                is.read(buf, 0, buf.length);
                is.reset();
                verifier.addMetaEntry(manifestEntry.getName(), buf);
            }
            try {
View Full Code Here

    IntDecoder decoder = encoder.createMatchingDecoder();
    decoder.reInit(bais);
   
    // -- Looping 100 times as a warm up --------------------------
    for (int i = 100; i != 0; --i) {
      bais.mark(baos.size());
      while (decoder.decode() != IntDecoder.EOS) {
      }
      bais.reset();
      decoder.reInit(bais);
    }
View Full Code Here

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

    decoder.reInit(bais);
    startTime = System.currentTimeMillis();
    for (int i = loopFactor; i > 0; --i) {
      bais.mark(baos.size());
      while (decoder.decode() != IntDecoder.EOS) {
      }
      bais.reset();
      decoder.reInit(bais);
    }
View Full Code Here

             * @see java.io.InputStream#mark(int)
             */
            @Override
            public synchronized void mark(int readlimit)
            {
                proxy.mark(readlimit);
            }

            /* (non-Javadoc)
             * @see java.io.InputStream#markSupported()
             */
 
View Full Code Here

            }
            else
            {

                ByteArrayInputStream stream = _remainingBufs.get(_currentListPos);
                stream.mark(0);
                return stream.read();
            }
        }

        @Override
View Full Code Here

        {
            _markPos = _currentListPos;
            final ByteArrayInputStream stream = _remainingBufs.get(_currentListPos);
            if(stream != null)
            {
                stream.mark(readlimit);
            }
        }

        @Override
        public void reset() throws IOException
View Full Code Here

            inStream.readFully(this.sname,  064);
            inStream.readFully(this.file,   0, 128);

            // check for DHCP MAGIC_COOKIE
            this.isDhcp = true;
            inBStream.mark(4);        // read ahead 4 bytes
            if (inStream.readInt() != _MAGIC_COOKIE) {
                this.isDhcp = false;
                inBStream.reset();    // re-read the 4 bytes
            }
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.