Package org.elasticsearch.river.wikipedia.bzip2

Examples of org.elasticsearch.river.wikipedia.bzip2.CBZip2InputStream$Data


                        if (istream.read() != magic[i]) {
                            throw new BuildException(
                                "Invalid bz2 file." + file.toString());
                        }
                    }
                    return new CBZip2InputStream(istream);
                }
            }
            return istream;
        }
View Full Code Here


                        if (istream.read() != magic[i]) {
                            throw new BuildException(
                                "Invalid bz2 file." + file.toString());
                        }
                    }
                    return new CBZip2InputStream(istream);
                }
            }
            return istream;
        }
View Full Code Here

        if (source.lastModified() > dest.lastModified()) {
            log("Expanding " + source.getAbsolutePath() + " to "
                + dest.getAbsolutePath());

            FileOutputStream out = null;
            CBZip2InputStream zIn = null;
            FileInputStream fis = null;
            BufferedInputStream bis = null;
            try {
                out = new FileOutputStream(dest);
                fis = new FileInputStream(source);
                bis = new BufferedInputStream(fis);
                int b = bis.read();
                if (b != 'B') {
                    throw new BuildException("Invalid bz2 file.", getLocation());
                }
                b = bis.read();
                if (b != 'Z') {
                    throw new BuildException("Invalid bz2 file.", getLocation());
                }
                zIn = new CBZip2InputStream(bis);
                byte[] buffer = new byte[8 * 1024];
                int count = 0;
                do {
                    out.write(buffer, 0, count);
                    count = zIn.read(buffer, 0, buffer.length);
                } while (count != -1);
            } catch (IOException ioe) {
                String msg = "Problem expanding bzip2 " + ioe.getMessage();
                throw new BuildException(msg, ioe, getLocation());
            } finally {
                if (bis != null) {
                    try {
                        bis.close();
                    } catch (IOException ioex) {
                        // ignore
                    }
                }
                if (fis != null) {
                    try {
                        fis.close();
                    } catch (IOException ioex) {
                        // ignore
                    }
                }
                if (out != null) {
                    try {
                        out.close();
                    } catch (IOException ioex) {
                        // ignore
                    }
                }
                if (zIn != null) {
                    try {
                        zIn.close();
                    } catch (IOException ioex) {
                        // ignore
                    }
                }
            }
View Full Code Here

        InputStream in = null;
        OutputStream out = stdout;
       
        for (File bzfile : files) {
            if (bzfile.getName().equals("-")) {
                processStream(new CBZip2InputStream(stdin), out);
                continue;
            }
            try {
                if (use_stdout) {
                    if ((in = new CBZip2InputStream(openFileRead(bzfile))) == null) {
                        rc = 1;
                        continue;
                    }
                    processStream(in, out);
                    continue;
                }
                try {
                    File file = stripSuffix(bzfile);
                    if ((out = openFileWrite(file, true, force)) == null) {
                        rc = 1;
                        continue;
                    }
                    if ((in = new CBZip2InputStream(openFileRead(bzfile))) == null) {
                        rc = 1;
                        continue;
                    }
                    processStream(in, out);
                    float sizeDiff = ((float) bzfile.length() / (float) file.length()) * 100;
 
View Full Code Here

    /**
     * Wraps an InputStream with a decompression stream for reading compressed archives.
     */
    private InputStream wrapInputStream(InputStream in) throws IOException {
        if (decompress == USE_BZIP) {
            return new CBZip2InputStream(in);
        }
        if (decompress == USE_GZIP) {
            return new GZIPInputStream(in, BUFFER_SIZE);
        }
       
View Full Code Here

      return;
    }
    // Read 2 bytes due to bug in BZip library
    compressedStream.read();
    compressedStream.read();
    InputStream stream = new CBZip2InputStream(compressedStream);
    BufferedReader reader = new BufferedReader(new InputStreamReader(stream));

    // Pattern find word name
    Pattern titlePattern = Pattern.compile("<title>([^<]+)</title>");
    // Pattern to find beginning of wiki text
View Full Code Here

        InputStream actualIn =
            new BufferedInputStream(new FileInputStream(actualFile));
        assertEquals((byte) 'B', actualIn.read());
        assertEquals((byte) 'Z', actualIn.read());

        originalIn = new CBZip2InputStream(originalIn);
        actualIn   = new CBZip2InputStream(actualIn);

        while (true) {
            int expected = originalIn.read();
            int actual   = actualIn.read();
            if (expected >= 0) {
View Full Code Here

        for (int i = 0; i < MAGIC.length; i++) {
            if (in.read() != MAGIC[i]) {
                throw new IOException("Invalid bz2 stream.");
            }
        }
        return new CBZip2InputStream(in);
    }
View Full Code Here

        if (source.lastModified() > dest.lastModified()) {
            log("Expanding " + source.getAbsolutePath() + " to "
                + dest.getAbsolutePath());

            FileOutputStream out = null;
            CBZip2InputStream zIn = null;
            InputStream fis = null;
            BufferedInputStream bis = null;
            try {
                out = new FileOutputStream(dest);
                fis = srcResource.getInputStream();
                bis = new BufferedInputStream(fis);
                int b = bis.read();
                if (b != 'B') {
                    throw new BuildException("Invalid bz2 file.", getLocation());
                }
                b = bis.read();
                if (b != 'Z') {
                    throw new BuildException("Invalid bz2 file.", getLocation());
                }
                zIn = new CBZip2InputStream(bis, true);
                byte[] buffer = new byte[BUFFER_SIZE];
                int count = 0;
                do {
                    out.write(buffer, 0, count);
                    count = zIn.read(buffer, 0, buffer.length);
                } while (count != -1);
            } catch (IOException ioe) {
                String msg = "Problem expanding bzip2 " + ioe.getMessage();
                throw new BuildException(msg, ioe, getLocation());
            } finally {
View Full Code Here

                        if (istream.read() != magic[i]) {
                            throw new BuildException(
                                "Invalid bz2 file." + file.toString());
                        }
                    }
                    return new CBZip2InputStream(istream);
                }
            }
            return istream;
        }
View Full Code Here

TOP

Related Classes of org.elasticsearch.river.wikipedia.bzip2.CBZip2InputStream$Data

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.