Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Tar file from Java

Posted on 2009-07-12
8
Medium Priority
?
340 Views
Last Modified: 2012-05-07
Does anybody know how to tar a file using ant tasks  org.apache.tools.ant.taskdefs.Tar..?

Thanks tons.
0
Comment
Question by:d2marcelo
  • 4
  • 4
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 24836831
the doco has lots of examples
http://ant.apache.org/manual/CoreTasks/tar.html
0
 

Author Comment

by:d2marcelo
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"));
      t.execute();

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)
0
 
LVL 92

Expert Comment

by:objects
ID: 24836851
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.

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:d2marcelo
ID: 24836885
objects,
do you use the TarArchive ?  if so , do you have an example?
thanks
0
 

Author Comment

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

Accepted Solution

by:
objects earned 2000 total points
ID: 24837639
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
0
 

Author Closing Comment

by:d2marcelo
ID: 31602684
This is great.!!   thanks again..
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

963 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