Tar file from Java

Does anybody know how to tar a file using ant tasks  org.apache.tools.ant.taskdefs.Tar..?

Thanks tons.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mick BarryJava DeveloperCommented:
the doco has lots of examples
d2marceloAuthor Commented:
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
      at org.apache.tools.ant.types.AbstractFileSet.setupDirectoryScanner(AbstractFileSet.java:382)
      at org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner(AbstractFileSet.java:356)
      at org.apache.tools.ant.taskdefs.Tar$TarFileSet.getFiles(Tar.java:473)
      at org.apache.tools.ant.taskdefs.Tar.execute(Tar.java:231)
Mick BarryJava DeveloperCommented:
I've always used trustice package http://www.trustice.com/java/tar/
you'll probably need to give it some context to use it outside ant, will check and get back top you.

Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

d2marceloAuthor Commented:
do you use the TarArchive ?  if so , do you have an example?
d2marceloAuthor Commented:
thanks objets, that works,
but would you happen to know how to use TarGzOutputStream? to compress it.
Mick BarryJava DeveloperCommented:
theres an example here http://www.coderanch.com/t/292263/JSP/java/Downloading-TarGz-file
or use a GZIPOutputStream for the output stream passed to TarArchive constructor

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
d2marceloAuthor Commented:
This is great.!!   thanks again..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.