Tar file from Java

Posted on 2009-07-12
Last Modified: 2012-05-07
Does anybody know how to tar a file using ant tasks

Thanks tons.
Question by:d2marcelo
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
LVL 92

Expert Comment

ID: 24836831
the doco has lots of examples

Author Comment

ID: 24836849
thanks objects,

here is my code

       Tar t = new Tar();
      t.setBasedir(new File("c:\\test"));
      t.setDestFile(new File("c:\\test.tar"));

I get

       Exception in thread "main" java.lang.NullPointerException
LVL 92

Expert Comment

ID: 24836851
I've always used trustice package
you'll probably need to give it some context to use it outside ant, will check and get back top you.

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now


Author Comment

ID: 24836885
do you use the TarArchive ?  if so , do you have an example?

Author Comment

ID: 24837613
thanks objets, that works,
but would you happen to know how to use TarGzOutputStream? to compress it.
LVL 92

Accepted Solution

objects earned 500 total points
ID: 24837639
theres an example here
or use a GZIPOutputStream for the output stream passed to TarArchive constructor

Author Closing Comment

ID: 31602684
This is great.!!   thanks again..

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question