Creation of Archive file with .tar format

Hi to all
Is there anybody that knows how to generate an archive file with .tar format ?
I have tried using a java service based upon com.ice.tar package, and then common-compress package, but I don’t succeed to produce my archive file…
If someone would have to realized this task before…I’d be glad to have some piece of information on that.

Thanks for your help !

Xavier

Apache Ant has some classes that allow you to create TAR files. You could download Ant and extract the classes you need into a separate JAR file. The classes are under the package org.apache.tools.tar (http://www.jajakarta.org/ant/ant-1.6.1/docs/en/manual/api/org/apache/tools/tar/package-summary.html)

Alternatively, if you’re not absolutely tied down to TAR, you could create JAR or ZIP files instead (via java.util.jar or java.util.zip), which in many cases, serves the exact same purpose.

Percio

You could use the apache commons compress library for creating tar files, there are very good examples of how to do it on the internet.

I got to admit though, this com.ice.tar has some really nice methods(like setKeepOldFiles,setTarProgressDisplay,setVerboseLogging etc) in it which are missing in the apache commons. Having said that, if i were you, i would stick to Apache commons libraries.

Go to http://commons.apache.org/compress/examples.html for how to implement creating a tar file under the tar section.

Adding an entry to a tar archive:

[COLOR=#000000][FONT=Verdana]
[COLOR=#660066]TarArchiveEntry[/color] entry [COLOR=#666600]=[/color] [COLOR=#000088]new[/color] [COLOR=#660066]TarArchiveEntry[/color][COLOR=#666600]([/color]name[COLOR=#666600]);[/color]
entry[COLOR=#666600].[/color]setSize[COLOR=#666600]([/color]size[COLOR=#666600]);[/color]
tarOutput[COLOR=#666600].[/color]putArchiveEntry[COLOR=#666600]([/color]entry[COLOR=#666600]);[/color]
tarOutput[COLOR=#666600].[/color]write[COLOR=#666600]([/color]contentOfEntry[COLOR=#666600]);[/color]
tarOutput[COLOR=#666600].[/color]closeArchiveEntry[COLOR=#666600]();[/color]
[/font][/COLOR]

Reading entries from an tar archive:

[COLOR=#000000][FONT=Verdana]
[COLOR=#660066]TarArchiveEntry[/color] entry [COLOR=#666600]=[/color] tarInput[COLOR=#666600].[/color]getNextTarEntry[COLOR=#666600]();[/color]
[COLOR=#000088]byte[/color][COLOR=#666600][][/color] content [COLOR=#666600]=[/color] [COLOR=#000088]new[/color] [COLOR=#000088]byte[/color][COLOR=#666600][[/color]entry[COLOR=#666600].[/color]getSize[COLOR=#666600]()];[/color]
LOOP UNTIL entry[COLOR=#666600].[/color]getSize[COLOR=#666600]()[/color] HAS BEEN READ [COLOR=#666600]{[/color]
    tarInput[COLOR=#666600].[/color]read[COLOR=#666600]([/color]content[COLOR=#666600],[/color] offset[COLOR=#666600],[/color] content[COLOR=#666600].[/color]length [COLOR=#666600]-[/color] offset[COLOR=#666600]);[/color]
[COLOR=#666600]}[/color][/font][/COLOR]

Cheers,
Akshith