Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Not A Bug
-
1.20
-
None
-
None
Description
public static void main(String args[]) throws Exception {
//Send the TAR file as an argument
String tarFileName = args[0];
/* Read TAR File into TarArchiveInputStream */
TarArchiveInputStream myTarFile=new TarArchiveInputStream(new FileInputStream(new File(tarFileName)));
/* To read individual TAR file */
TarArchiveEntry entry = null;
String individualFiles;
int offset;
FileOutputStream outputFile=null;
/* Create a loop to read every single entry in TAR file */
while ((entry = myTarFile.getNextTarEntry()) != null)
I was able to decompress the tar file in the Linux environment using the tar command. Following is the error when I run the code:
[ec2-user@ip-172-31-16-85 src]$ java TarToByteArray.java layer1.tar
Error: Could not find or load main class TarToByteArray.java
[ec2-user@ip-172-31-16-85 src]$ java TarToByteArray layer1.tar
Exception in thread "main" java.io.IOException: Error detected parsing the header
at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getNextTarEntry(TarArchiveInputStream.java:371)
at TarToByteArray.main(TarToByteArray.java:19)
Caused by: java.lang.IllegalArgumentException: At offset 124, 12 byte binary number exceeds maximum signed long value
at org.apache.commons.compress.archivers.tar.TarUtils.parseBinaryBigInteger(TarUtils.java:215)
at org.apache.commons.compress.archivers.tar.TarUtils.parseOctalOrBinary(TarUtils.java:179)
at org.apache.commons.compress.archivers.tar.TarArchiveEntry.parseTarHeader(TarArchiveEntry.java:1350)
at org.apache.commons.compress.archivers.tar.TarArchiveEntry.<init>(TarArchiveEntry.java:438)
at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getNextTarEntry(TarArchiveInputStream.java:369)
... 1 more
Also attaching the tar file that I am using!