Package java.io

Examples of java.io.InputStream.mark()


              } catch (Exception e1) {
                // Fall back to the format used by EJBCA WS RA CLI stress test
                System.out.println("Parsing as textfile failed ("+e1.getMessage()+"). Trying to use it as a file with Java Objects.");
                vSerialNrsTmp = new ArrayList<BigInteger>();
                    InputStream is = new BufferedInputStream(new FileInputStream(fileName));
                    is.mark(1);
                    try {
                        ObjectInput oi = null;
                        while( true ) {
                            for ( int i=100; oi==null && i>0; i--) {
                                is.reset();
View Full Code Here


                        ObjectInput oi = null;
                        while( true ) {
                            for ( int i=100; oi==null && i>0; i--) {
                                is.reset();
                                try {
                                    is.mark(i);
                                    oi = new ObjectInputStream(is);
                                } catch( StreamCorruptedException e) {
                                    is.reset();
                                    is.read();
                                }
View Full Code Here

                            }
                            if ( oi==null ) {
                                break;
                            }
                            try {
                                is.mark(100);
                                vSerialNrsTmp.add((BigInteger)oi.readObject());
                            } catch( StreamCorruptedException e ) {
                                oi=null;
                            }
                        }
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

            }
            // workaround for pre-1.3 VMs that don't recognize UTF-16
            if (version.startsWith("1.2"|| version.startsWith("1.1")) {
                if (encoding.equalsIgnoreCase("UTF-16")) {
                    // is it  big-endian or little-endian?
                    in.mark(2);
                    int first = in.read();
                    if (first == 0xFF) encoding = "UnicodeLittle";
                    else encoding="UnicodeBig";
                    in.reset()
                }
View Full Code Here

    }

    private BundleInstallerResult doInstallBundleIfNeeded(String bundleLocation, int startLevel) throws IOException, BundleException {
        InputStream is = getInputStreamForBundle(bundleLocation);
        try {
            is.mark(256 * 1024);
            @SuppressWarnings("resource")
            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

                    DOMSource domSrc = (DOMSource)src;
                    doc = (SVGDocument)domSrc.getNode();
                } else {
                    in = new UnclosableInputStream(ImageUtil.needInputStream(src));
                    int length = in.available();
                    in.mark(length + 1);
                    SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(
                            getParserName());
                    doc = factory.createSVGDocument(src.getSystemId(), in);
                }
                ImageInfo info = createImageInfo(uri, context, doc);
View Full Code Here

    try {
      // I need to be able to move back in the stream if this is not a pb serialization so I can
      // do the Writable decoding instead.
      in = in.markSupported()? in: new BufferedInputStream(in);
      int pblen = ProtobufUtil.lengthOfPBMagic();
      in.mark(pblen);
      byte [] pbuf = new byte[pblen];
      int read = in.read(pbuf);
      if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen);
      // WATCHOUT! Return in middle of function!!!
      if (ProtobufUtil.isPBMagicPrefix(pbuf)) return convert(FSProtos.Reference.parseFrom(in));
View Full Code Here

  private BundleInstallerResult doInstallBundleIfNeeded(
      String bundleLocation, int startLevel) throws IOException,
      BundleException {
    InputStream is = getInputStreamForBundle(bundleLocation);
    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 "
View Full Code Here

                entry = zip.getNextZipEntry();
                continue;
            }

            InputStream entryStream = new BufferedInputStream(zip, 4096);
            entryStream.mark(4096);
            IWORKDocumentType type = IWORKDocumentType.detectType(entryStream);
            entryStream.reset();
           
            if(type != null) {
               XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
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.