Package org.elasticsearch.common.compress.bzip2

Examples of org.elasticsearch.common.compress.bzip2.CBZip2InputStream


        final int b2 = is.read();
        if (b1 != 'B' || b2 != 'Z')
        {
            throw new FileSystemException("vfs.provider.compressedFile/not-a-compressedFile-file.error", name);
        }
        return new CBZip2InputStream(is);
    }
View Full Code Here


            if (sourcefile.getName().endsWith(".bz2")) {
                int b = is.read();
                if (b != 'B') throw new IOException("Invalid bz2 content.");
                b = is.read();
                if (b != 'Z') throw new IOException("Invalid bz2 content.");
                is = new CBZip2InputStream(is);
            } else if (sourcefile.getName().endsWith(".gz")) {
                is = new GZIPInputStream(is);
            }
            BufferedReader r = new BufferedReader(new java.io.InputStreamReader(is, "UTF-8"), 4 * 1024 * 1024);
            String t;
View Full Code Here

                throw new Exception("Invalid bz2 content.");
            }          
           
            int read = 0;
            final byte[] data = new byte[1024];
            final CBZip2InputStream zippedContent = new CBZip2InputStream(source);       
           
            tempFile = File.createTempFile("bunzip","tmp");
            tempFile.deleteOnExit();
           
            // creating a temp file to store the uncompressed data
            final FileOutputStream out = new FileOutputStream(tempFile);
           
            // reading gzip file and store it uncompressed
            while((read = zippedContent.read(data, 0, 1024)) != -1) {
                out.write(data, 0, read);
            }
            zippedContent.close();
            out.close();
           
            // creating a new parser class to parse the unzipped content
            docs = TextParser.parseSource(location, null, null, tempFile);
        } catch (final Exception e) { 
View Full Code Here

          for (int i = 0; i < magic.length; i++) {
            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." + name);
                        }
                    }
                    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.", location);
                }
                b = bis.read();
                if (b != 'Z') {
                    throw new BuildException("Invalid bz2 file.", location);
                }
                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, location);
            } finally {
                if (bis != null) {
                    try {
                        bis.close();
                    } catch (IOException ioex) {}
                }
                if (fis != null) {
                    try {
                        fis.close();
                    } catch (IOException ioex) {}
                }
                if (out != null) {
                    try {
                        out.close();
                    } catch (IOException ioex) {}
                }
                if (zIn != null) {
                    try {
                        zIn.close();
                    } catch (IOException ioex) {}
                }
            }
        }
    }
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 (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

TOP

Related Classes of org.elasticsearch.common.compress.bzip2.CBZip2InputStream

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.