Package org.apache.tools.bzip2

Examples of org.apache.tools.bzip2.CBZip2OutputStream$Data


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


      LOG.info("Reading deletes from " + deletesFile);
     
      FileInputStream fin = new FileInputStream(deletesFile);
      byte[] ignoreBytes = new byte[2];
      fin.read(ignoreBytes); // "B", "Z" bytes from commandline tools
      BufferedReader br = new BufferedReader(new InputStreamReader(new CBZip2InputStream(fin)));

      String s;
      while ((s = br.readLine()) != null) {
        if (s.contains("\t")) {
          deletes.add(Long.parseLong(s.split("\t")[0]));
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, false);
        } catch (final Exception e) {
View Full Code Here

        if (b != 'B')
            throw new IOException(tr("Invalid bz2 file."));
        b = bis.read();
        if (b != 'Z')
            throw new IOException(tr("Invalid bz2 file."));
        return new CBZip2InputStream(bis, /* see #9537 */ true);
    }
View Full Code Here

        InputStream is = resource.read();
        try {
            // CBZip2InputStream expects the opening "BZ" to be skipped
            byte[] skip = new byte[2];
            is.read(skip);
            return new CBZip2InputStream(is);
        } catch (Exception e) {
            String message = String.format("Unable to create bzip2 input stream for resource %s.", resource.getDisplayName());
            throw new ResourceException(message, e);
        }
    }
View Full Code Here

            throw new IOException("Not BZIP2 format");
        }
        if (in.read() != 'Z') {
            throw new IOException("Not BZIP2 format");
        }
        BufferedInputStream gzis = new BufferedInputStream(new CBZip2InputStream(in));
        String path = doc.get("path");
        if (path != null &&
                (path.endsWith(".bz2") || path.endsWith(".BZ2") || path.endsWith(".bz"))
                ) {
            String newname = path.substring(0, path.lastIndexOf('.'));
View Full Code Here

                    outStr = new GZIPOutputStream(outStr);
                    break;
                case BZIP2:
                    outStr.write('B');
                    outStr.write('Z');
                    outStr = new CBZip2OutputStream(outStr);
                    break;
            }
            tarOutStr = new TarOutputStream(outStr);
            tarOutStr.setLongFileMode(TarOutputStream.LONGFILE_GNU);
        } catch (Exception e) {
View Full Code Here

    {
        OutputStream os = getContainer().getContent().getOutputStream(false);
        os.write('B');
        os.write('Z');

        return new CBZip2OutputStream(os);
    }
View Full Code Here

                return new GZIPOutputStream(ostream);
            } else {
                if (BZIP2.equals(v)) {
                    ostream.write('B');
                    ostream.write('Z');
                    return new CBZip2OutputStream(ostream);
                }
            }
            return ostream;
        }
View Full Code Here

* @ant.task category="packaging"
*/

public class BZip2 extends Pack {
    protected void pack() {
        CBZip2OutputStream zOut = null;
        try {
            BufferedOutputStream bos =
                new BufferedOutputStream(new FileOutputStream(zipFile));
            bos.write('B');
            bos.write('Z');
            zOut = new CBZip2OutputStream(bos);
            zipFile(source, zOut);
        } catch (IOException ioe) {
            String msg = "Problem creating bzip2 " + ioe.getMessage();
            throw new BuildException(msg, ioe, location);
        } finally {
            if (zOut != null) {
                try {
                    // close up
                    zOut.close();
                } catch (IOException e) {}
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tools.bzip2.CBZip2OutputStream$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.