Solved

Tar file from Java

Posted on 2009-07-12
8
337 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
[X]
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
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
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

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 500 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

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