Solved

Tar file from Java

Posted on 2009-07-12
8
332 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

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

Expert Comment

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
github account with ecipse 1 47
how do i compare an object based on two fields 6 53
Java string replace 11 46
pagenation logic how it is working in my code 1 29
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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

770 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