Package java.io

Examples of java.io.InputStream.reset()


    in = new BufferedInputStream(new ByteArrayInputStream(bytes), 12);
    try {
      in.skip(6);
      in.mark(8);
      in.skip(7);
      in.reset();
      assertTrue("Wrong bytes 2", in.read() == 6 && in.read() == 7);
    } catch (IOException e) {
      fail("Exception during mark test 3");
    }
  }
View Full Code Here


        try {
            in.mark(MB);
            try {
                message = clientResponse.getEntity(APIResult.class).getMessage();
            } catch (Throwable e) {
                in.reset();
                message = clientResponse.getEntity(InstancesResult.class).getMessage();
            }
        } catch (Throwable t) {
            byte[] data = new byte[MB];
            try {
View Full Code Here

                message = clientResponse.getEntity(InstancesResult.class).getMessage();
            }
        } catch (Throwable t) {
            byte[] data = new byte[MB];
            try {
                in.reset();
                int len = in.read(data);
                message = new String(data, 0, len);
            } catch (IOException e) {
                message = e.getMessage();
            }
View Full Code Here

                        in.close();
                        modifyZipEntry(out_entry, bytes, crc32);
                        in = new ByteArrayInputStream(bytes);
                    } else {
                        // the classfile has not been enhanced
                        in.reset();
                    }
                }

                // copy the entry
                zip_out.putNextEntry(out_entry);
View Full Code Here

                // 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

            while (-1 != in.read()) {
                // loop
            }
            assertTrue(in.markSupported());
            try {
                in.reset();
            } catch (Exception e) {
                fail("Unexpected exception while resetting input stream: " + e.getMessage());
            }

            // test integrity of replayed bytes
View Full Code Here

    InputStream data = new ByteArrayInputStream(DATA);
    InputStream in = new LimitInputStream(data, 10);
    assertTrue(in.available() > 0);
    in.mark(100);
    in.read(new byte[20]);
    in.reset();
    assertTrue(in.available() > 0);
  }

  @Test
  public void testSkip() throws IOException
View Full Code Here

                        // force the stream to wait for input
                        bytesAvailable = is.available();
                        if (bytesAvailable < buf.length) {
                            bytesRead = is.read(buf, 0, bytesAvailable + 1);
                            // Reset so that we "unread" the bytes that we read
                            is.reset();
                            if (bytesRead == -1)
                                break;
                        } else {
                            // Make the buffer larger
                            if (buf.length < Integer.MAX_VALUE / 2)
View Full Code Here

                        return b;
                    }
                }
            }
            try {
                is.reset();
            } catch (IOException e) {
                is.close();
                is = new BufferedInputStream(new URL(bundleLocation).openStream());
            }
            LOGGER.debug("Installing bundle " + bundleLocation);
View Full Code Here

        try {
            return entityParser.parse(xmlStream);
        } catch (FalconException e) {
            if (LOG.isDebugEnabled() && xmlStream.markSupported()) {
                try {
                    xmlStream.reset();
                    String xmlData = getAsString(xmlStream);
                    LOG.debug("XML DUMP for (" + entityType + "): " + xmlData, e);
                } catch (IOException ignore) {
                    // ignore
                }
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.