File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create tar using Java in windows os

 
satya sahu
Ranch Hand
Posts: 97
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI all,
I have to take some backup of some files from my application using java program. The final output should be in .tar format because this backed up data will be used in the application running in linux box and the linux box due to limited space does not have any other utilities like GZIP or unzip. Only the tar is supported. Hence i need to produce the back up data in tar format.
Please advice me how to do it in windows environment ?
Sample code will be really great help for me.

Thanks in advance.
Satya
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use cygwin to run *nix programs under Windows.
 
Sev Zaslavsky
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like there are at least 3 approaches:

1. Call "tar" using one of the flavors of java.lang.Runtime.exec() . Note that this might not be portable. Joe Ess alluded how to get a "tar" that runs on windows
2. Find a tar library written in java and code against it. Here is something I found on Google search that alludes to such a library http://bugs.gentoo.org/show_bug.cgi?id=75343
3. Instear of tar, use jar for which java has built-in support. zip/unzip utilities are tiny in size in relation to the archives that you'll be making. This might be the path of least effort.

Which do you like best?
[ November 26, 2008: Message edited by: Sev Zaslavsky ]
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another Java tar library is Apache Commons Compress. It's currently available as source code only, but it works well.
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can use the GZIPOutputStream class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic