Package java.util.zip

Examples of java.util.zip.GZIPInputStream


public class tarTools {
 
  public static InputStream getInputStream(final String tarFileName) throws Exception{
    if (tarFileName.endsWith(".gz")) {
        try {
            return new GZIPInputStream(new FileInputStream(new File(tarFileName)));
        } catch (IOException e) {
            // this might happen if the stream is not in gzip format.
            // there may be a 'gz' extension, but it may stil be a raw tar file
            // this can be caused by 'one too much gzip-content header' that was attached
            // by a release file server
View Full Code Here


        int count = 0;

        System.out.println("start processing");
        try {
            InputStream is = new BufferedInputStream(new FileInputStream(infile));
            if (gz) is = new GZIPInputStream(is);
            reader = new BufferedReader(new InputStreamReader(is));
            String line;
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.length() > 0) {
View Full Code Here

        int count = 0;

        System.out.println("start processing");
        try {
            InputStream is = new BufferedInputStream(new FileInputStream(infile));
            if (gz) is = new GZIPInputStream(is);
            reader = new BufferedReader(new InputStreamReader(is));
            String line;
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.length() > 0) {
View Full Code Here

        final long cleanuplimit = Math.max(50 * 1024 * 1024, MemoryControl.available() / 8);

        System.out.println("start processing");
        try {
            InputStream is = new BufferedInputStream(new FileInputStream(infile));
            if (gz) is = new GZIPInputStream(is);
            reader = new BufferedReader(new InputStreamReader(is));
            String line;
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.length() > 0) {
View Full Code Here

     * @throws IOException
     */
    public static byte[] decompress(byte[] compressedData) throws IOException {
       
        ByteArrayInputStream bis = new ByteArrayInputStream(compressedData);
        GZIPInputStream in = new GZIPInputStream(bis);
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
       
        byte[] transferBuffer = new byte[4096];
        int read = 0;
        do {
            read = in.read(transferBuffer);
            if (read != -1) {
                bos.write(transferBuffer, 0, read);
            }
        } while (read != -1);
        in.close();
               
        in.close();
        bos.close();
       
        return bos.toByteArray();
    }
View Full Code Here

    super(entity);
  }

  public InputStream getContent() throws IOException, IllegalStateException {
    if (gzipInputStream == null) {
      gzipInputStream = new GZIPInputStream(wrappedEntity.getContent());
    }
    return gzipInputStream;
  }
View Full Code Here

        this.keys = new ConcurrentHashMap<String, Object>();
       
        if (file.exists()) {
            InputStream is = new FileInputStream(file);
            if (file.getName().endsWith(".gz")) {
                is = new GZIPInputStream(is);
            }
            final BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            String l;
            try {
                while ((l = reader.readLine()) != null) {
View Full Code Here

     * @throws IOException
     */
    public static byte[] decompress(byte[] compressedData) throws IOException {
       
        ByteArrayInputStream bis = new ByteArrayInputStream(compressedData);
        GZIPInputStream in = new GZIPInputStream(bis);
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
       
        byte[] transferBuffer = new byte[4096];
        int read = 0;
        do {
            read = in.read(transferBuffer);
            if (read != -1) {
                bos.write(transferBuffer, 0, read);
            }
        } while (read != -1);
        in.close();
               
        in.close();
        bos.close();
       
        return bos.toByteArray();
    }
View Full Code Here

   * @throws IOException
   */
  public static String unzipStringFromBytes(byte[] bytes) throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
    BufferedInputStream bufis = new BufferedInputStream(
        new GZIPInputStream(bis));
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    byte[] buf = new byte[1024];
    int len;
    while ((len = bufis.read(buf)) > 0) {
      bos.write(buf, 0, len);
View Full Code Here

    try {
      if(outFilename == null) {
        outFilename = inFilename.substring(0, inFilename.lastIndexOf("."));
      }
     
      GZIPInputStream in = new GZIPInputStream(new FileInputStream(inFilename));
     
      java.io.OutputStream out = new FileOutputStream(outFilename);
     
     
      byte[] buf = new byte[1024];
      int len;
      while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
      }
     
      in.close();
      out.close();
    } catch (Exception e) {
      throw e;
    }
   
View Full Code Here

TOP

Related Classes of java.util.zip.GZIPInputStream

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.