Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-137

TarArchiveEntry.getFile() always returns null + no way to get an InputStream from TarArchiveInputStream similar to what you do with (java.util.zip.ZipFile())..getInputStream(ZipEntry);

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Not A Problem
    • 1.1
    • 1.1
    • Compressors

    Description

      ~
      this is a test run using httpd-2.2.19.tar[.gz,bz2] to show what I mean
      ~
      lbrtchx
      ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
      $ wget http://apache.cyberuse.com//httpd/httpd-2.2.19.tar.gz
      -2011-06-27 11:21:46- http://apache.cyberuse.com//httpd/httpd-2.2.19.tar.gz
      Resolving apache.cyberuse.com... 174.132.149.89
      Connecting to apache.cyberuse.com|174.132.149.89|:80... connected.
      HTTP request sent, awaiting response... 200 OK
      Length: 7113418 (6.8M) [application/x-gzip]
      Saving to: `httpd-2.2.19.tar.gz'

      100%[===...===>] 7,113,418 296K/s in 24s

      2011-06-27 11:22:10 (285 KB/s) - `httpd-2.2.19.tar.gz' saved [7113418/7113418]

      $ wget http://apache.cyberuse.com//httpd/httpd-2.2.19.tar.bz2
      -2011-06-27 11:22:19- http://apache.cyberuse.com//httpd/httpd-2.2.19.tar.bz2
      Resolving apache.cyberuse.com... 174.132.149.89
      Connecting to apache.cyberuse.com|174.132.149.89|:80... connected.
      HTTP request sent, awaiting response... 200 OK
      Length: 5322082 (5.1M) [application/x-bzip2]
      Saving to: `httpd-2.2.19.tar.bz2'

      100%[===...===>] 5,322,082 256K/s in 25s

      2011-06-27 11:22:44 (207 KB/s) - `httpd-2.2.19.tar.bz2' saved [5322082/5322082]

      $ wget http://www.apache.org/dist/httpd/httpd-2.2.19.tar.gz.md5
      -2011-06-27 11:22:51- http://www.apache.org/dist/httpd/httpd-2.2.19.tar.gz.md5
      Resolving www.apache.org... 140.211.11.131
      Connecting to www.apache.org|140.211.11.131|:80... connected.
      HTTP request sent, awaiting response... 200 OK
      Length: 54 [text/plain]
      Saving to: `httpd-2.2.19.tar.gz.md5'

      100%[===...===>] 54 --.-K/s in 0s

      2011-06-27 11:22:51 (4.23 MB/s) - `httpd-2.2.19.tar.gz.md5' saved [54/54]

      $ wget http://www.apache.org/dist/httpd/httpd-2.2.19.tar.bz2.md5
      -2011-06-27 11:23:02- http://www.apache.org/dist/httpd/httpd-2.2.19.tar.bz2.md5
      Resolving www.apache.org... 140.211.11.131
      Connecting to www.apache.org|140.211.11.131|:80... connected.
      HTTP request sent, awaiting response... 200 OK
      Length: 55 [text/plain]
      Saving to: `httpd-2.2.19.tar.bz2.md5'

      100%[===...===>] 55 --.-K/s in 0s

      2011-06-27 11:23:02 (4.91 MB/s) - `httpd-2.2.19.tar.bz2.md5' saved [55/55]

      $ ls -l httpd-2.2.19.tar.*
      rw-rr- 1 knoppix knoppix 5322082 May 21 18:58 httpd-2.2.19.tar.bz2
      rw-rr- 1 knoppix knoppix 55 May 21 18:58 httpd-2.2.19.tar.bz2.md5
      rw-rr- 1 knoppix knoppix 7113418 May 21 18:58 httpd-2.2.19.tar.gz
      rw-rr- 1 knoppix knoppix 54 May 21 18:58 httpd-2.2.19.tar.gz.md5
      $ md5sum -b httpd-2.2.19.tar.bz2
      832f96a6ec4b8fc7cf49b9efd4e89060 *httpd-2.2.19.tar.bz2
      $ md5sum -b httpd-2.2.19.tar.gz
      e9f5453e1e4d7aeb0e7ec7184c6784b5 *httpd-2.2.19.tar.gz
      $ cat *.md5
      832f96a6ec4b8fc7cf49b9efd4e89060 *httpd-2.2.19.tar.bz2
      e9f5453e1e4d7aeb0e7ec7184c6784b5 *httpd-2.2.19.tar.gz

      ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

      /*
      TarArchiveEntry.getFile() always returns null + no way to get an InputStream from TarArchiveInputStream similar to what you do with (java.util.zip.ZipFile())..getInputStream(ZipEntry);
      */

      import org.apache.commons.compress.compressors.bzip2.*;
      import org.apache.commons.compress.compressors.gzip.*;
      import org.apache.commons.compress.archivers.tar.*;
      import org.apache.commons.compress.utils.*;
      import org.apache.commons.compress.archivers.*;

      import java.io.*;
      import java.util.*;
      import java.text.*;

      // __
      public class TAR00Test{
      // __
      public static void main(String[] args){
      // __
      TarArchiveInputStream TArkIS = null;
      TarArchiveEntry TArkEntry = null;

      File TARFl, IFl, IDir = new File("/media/sda1/prjx/sw/text_synch/XML_Fls/test");
      String[] aIFl = new String[]

      {"httpd-2.2.19.tar.bz2", "httpd-2.2.19.tar.gz"}

      ;

      String aFlPth;
      // __
      try{
      for(int i = 0; (i < aIFl.length); ++i){
      IFl = new File(IDir, aIFl[i]);
      aFlPth = IFl.getCanonicalPath();
      if(IFl.exists()){
      aFlPth = aFlPth.toLowerCase();
      // __
      if(aFlPth.endsWith(".tar.bz2"))

      { TArkIS = new TarArchiveInputStream(new BZip2CompressorInputStream(new FileInputStream(IFl))); }

      else if(aFlPth.endsWith(".tar.gz"))

      { TArkIS = new TarArchiveInputStream(new GzipCompressorInputStream(new FileInputStream(IFl))); }

      else{} // ...
      // __
      TArkEntry = (TarArchiveEntry)TArkIS.getNextEntry();
      while(TArkEntry != null){
      if(!TArkEntry.isDirectory()){
      System.err.println(TArkEntry);
      // __ org/apache/commons/compress/archivers/tar/TarArchiveEntry.html
      System.err.println("// __ getName: |" + TArkEntry.getName() + "|");
      System.err.println("// __ getSize: |" + TArkEntry.getSize() + "|");
      System.err.println("// __ getUserId: |" + TArkEntry.getUserId() + "|");
      System.err.println("// __ GroupId: |" + TArkEntry.getGroupId() + "|");
      System.err.println("// __ GroupName: |" + TArkEntry.getGroupName() + "|");
      System.err.println("// __ LastModifiedDate: |" + TArkEntry.getLastModifiedDate() + "|");
      System.err.println("// __ LinkName: |" + TArkEntry.getLinkName() + "|");
      System.err.println("// __ Mode: |" + TArkEntry.getMode() + "|");
      System.err.println("// __ ModTime: |" + TArkEntry.getModTime() + "|");
      TARFl = TArkEntry.getFile();
      System.err.println("// __ File: |" + TARFl + "|");

      if(TARFl != null)

      { System.err.println("~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~"); }

      else

      { System.err.println("~"); }

      }
      TArkEntry = (TarArchiveEntry)TArkIS.getNextEntry();
      }
      // __
      TArkIS.close();
      }// (IFl.exists())
      else

      { System.err.println("// __ File not found! |" + aFlPth + "|"); }

      }// i [0, aIFl.length)
      }catch(FileNotFoundException FlNFX)

      { FlNFX.printStackTrace(System.err); }

      catch(IOException IOX)

      { IOX.printStackTrace(System.err); }

      }
      }

      Attachments

        Activity

          People

            tcurdt Torsten Curdt
            lbrtchx Albretch Mueller
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: