Package org.apache.commons.io.input

Examples of org.apache.commons.io.input.CloseShieldInputStream


    public void parse(
            InputStream stream, ContentHandler handler, Metadata metadata)
            throws IOException, SAXException, TikaException {
        // Protect the stream from being closed by CyberNeko
        stream = new CloseShieldInputStream(stream);

        // Prepare the HTML content handler that generates proper
        // XHTML events to records relevant document metadata
        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
        XPathParser xpath = new XPathParser(null, "");
View Full Code Here


            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setValidating(false);
            factory.setNamespaceAware(true);
            SAXParser parser = factory.newSAXParser();
            parser.parse(
                    new CloseShieldInputStream(stream),
                    new NSNormalizerContentHandler(dh));
        } catch (ParserConfigurationException e) {
            throw new TikaException("XML parser configuration error", e);
        }
    }
View Full Code Here

        xhtml.startDocument();

        // At the end we want to close the gzip stream to release any associated
        // resources, but the underlying document stream should not be closed
        InputStream gzip =
            new GZIPInputStream(new CloseShieldInputStream(stream));
        try {
            Metadata entrydata = new Metadata();
            String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
            if (name != null) {
                if (name.endsWith(".tgz")) {
View Full Code Here

            xhtml.characters("\n");
        }

        try {
            getParser().parse(
                    new CloseShieldInputStream(stream),
                    new BodyContentHandler(xhtml),
                    metadata);
            xhtml.characters("\n");
        } catch (TikaException e) {
            // Could not parse the entry, just skip the content
View Full Code Here

            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setNamespaceAware(true);
            factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
            SAXParser parser = factory.newSAXParser();
            parser.parse(
                    new CloseShieldInputStream(stream),
                    new OfflineContentHandler(
                            getContentHandler(handler, metadata)));
        } catch (ParserConfigurationException e) {
            throw new TikaException("XML parser configuration error", e);
        }
View Full Code Here

        xhtml.startDocument();

        // At the end we want to close the gzip stream to release any associated
        // resources, but the underlying document stream should not be closed
        InputStream gzip =
            new GZIPInputStream(new CloseShieldInputStream(stream));
        try {
            Metadata entrydata = new Metadata();
            String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
            if (name != null) {
                if (name.endsWith(".tgz")) {
View Full Code Here

            xhtml.element("h1", name);
        }

        try {
            getParser().parse(
                    new CloseShieldInputStream(stream),
                    new EmbeddedContentHandler(new BodyContentHandler(xhtml)),
                    metadata);
        } catch (TikaException e) {
            // Could not parse the entry, just skip the content
        }
View Full Code Here

            Iterator<ImageReader> iterator =
                ImageIO.getImageReadersByMIMEType(type);
            if (iterator.hasNext()) {
                ImageReader reader = iterator.next();
                reader.setInput(ImageIO.createImageInputStream(
                        new CloseShieldInputStream(stream)));
                metadata.set("height", Integer.toString(reader.getHeight(0)));
                metadata.set("width", Integer.toString(reader.getWidth(0)));
                reader.dispose();
            }
        }
View Full Code Here

            factory.setValidating(false);
            factory.setNamespaceAware(true);
            factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
            SAXParser parser = factory.newSAXParser();
            parser.parse(
                    new CloseShieldInputStream(stream),
                    new OfflineContentHandler(
                            new NSNormalizerContentHandler(dh)));
        } catch (ParserConfigurationException e) {
            throw new TikaException("XML parser configuration error", e);
        }
View Full Code Here

        xhtml.startDocument();

        // At the end we want to close the bzip2 stream to release any associated
        // resources, but the underlying document stream should not be closed
        InputStream gzip =
            new CBZip2InputStream(new CloseShieldInputStream(stream));
        try {
            Metadata entrydata = new Metadata();
            String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
            if (name != null) {
                if (name.endsWith(".tbz")) {
View Full Code Here

TOP

Related Classes of org.apache.commons.io.input.CloseShieldInputStream

Copyright © 2018 www.massapicom. 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.