Package java.io

Examples of java.io.InputStream.mark()


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


    }

    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

    private static String getMessage(ClientResponse clientResponse) {
        String message;
        clientResponse.bufferEntity();
        InputStream in = clientResponse.getEntityInputStream();
        try {
            in.mark(MB);
            try {
                message = clientResponse.getEntity(APIResult.class).getMessage();
            } catch (Throwable e) {
                in.reset();
                message = clientResponse.getEntity(InstancesResult.class).getMessage();
View Full Code Here

                    // we have to copy the classfile, because if it won't be
                    // enhanced, the OutputStream is empty and we have to
                    // re-read the InputStream, which is impossible with a
                    // ZipInputStream (no mark/reset)
                    in = openZipEntry(zip_in);
                    in.mark(Integer.MAX_VALUE);
                    final ByteArrayOutputStream tmp
                        = new ByteArrayOutputStream();
                    if (enhancer.enhanceClassFile(in, tmp)) {
                        enhanced = true;
                        final byte[] bytes = tmp.toByteArray();
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) {
                    DocumentBuilder docBuilder = DomUtil.BUILDER_FACTORY.newDocumentBuilder();
                    requestDocument = docBuilder.parse(bin);
View Full Code Here

        try {
            // test whether mark and reset works
            assertTrue(in instanceof DbInputStream);
            in = new BufferedInputStream(in);
            assertTrue(in.markSupported());
            in.mark(data.length);
            while (-1 != in.read()) {
                // loop
            }
            assertTrue(in.markSupported());
            try {
View Full Code Here

  public void testMarkAndReset() throws IOException
  {
    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);
  }
View Full Code Here

            try {
                while (true) {
                    synchronized (is) {
                        // Mark the stream position so that other threads can
                        // reread the strea
                        is.mark(buf.length);
                        // Read one more byte than has already been read to
                        // force the stream to wait for input
                        bytesAvailable = is.available();
                        if (bytesAvailable < buf.length) {
                            bytesRead = is.read(buf, 0, bytesAvailable + 1);
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

        throws IOException, FalconException {

        EntityParser<?> entityParser = EntityParserFactory.getParser(entityType);
        InputStream xmlStream = request.getInputStream();
        if (xmlStream.markSupported()) {
            xmlStream.mark(XML_DEBUG_LEN); // mark up to debug len
        }
        try {
            return entityParser.parse(xmlStream);
        } catch (FalconException e) {
            if (LOG.isDebugEnabled() && xmlStream.markSupported()) {
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.