Results 1 to 4 of 4
  1. #1
    ashu_knw is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default create the tar.gz file for UNIX plateform in java

    Hi,

    I have the requirment to tar the folder which containing the some file. this tar file should work in UNIX plateform menas we can un tar it on UNIX machine.

    Could someone please provide me some sample code for this?

    Thanks.

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by ashu_knw View Post
    Could someone please provide me some sample code for this?

    the examples from the man tar on AIX

    Java Code:
    Examples
           1    To write the file1 and file2 files to a new archive on the default tape drive, enter:
                tar -c file1 file2
    
           2    To extract all files in the /tmp directory from the archive file on the /dev/rmt2 tape
                device and use the time of extraction as the modification time, enter:
    
                tar -xm -f/dev/rmt2 /tmp
           3    To create a new archive file that contains the file1 file and pass the archive file to
                the dd command to be written to the /dev/rmt1 device, enter:
    
                tar -cvf - file1 | dd of=/dev/rmt1 conv=sync
           4    To display the names of the files in the out.tar disk archive file on the current
                directory, enter:
    
                tar -vtf out.tar
           5    To expand the compressed tar archive file, fil.tar.z, pass the file to the tar
                command, and extract all files from the expanded tar archive file, enter:
    
                zcat fil.tar.Z | tar -xvf -
           6    To archive the contents of /usr/include and /usr/bin files using short relative path
                names, enter:
    
                cd /usr
                tar -cvf/dev/rmt0 -C./include . -C ../bin .
    
           7    To archive to an 8-mm device when using the -S flag, enter:
    
                tar -cvf /dev/rmt0 -S 4800000b /usr
    
                Note: When archiving to an 8-mm device, the -S Feet and -S Feet@Density flags are not
                recommended, since the 8-mm device does not use the concept of density when writing to
                a tape.
           8    To archive a list of all C files that is listed in the file through the InputList
                argument of the -L option, enter:
    
                tar -cvf fl.tar -L fl_list
                Where fl_list is a file consisting a list of all .c files in it. This can be obtained
                as follows:
    
                ls *.c > fl_list
           9    To archive a list of all C files by setting a variable using the -L option, enter:
    
                ls *.c > fl_list
                fl=fl_list
                tar -cvf var.tar -L $fl
           10   To avoid the truncation of long user or group names during creation of the archive,
                enter:
    
                tar -cvEf file.tar file
           11   To create a new archive file that contains the file1 file with ACL and EA, enter:
    
                tar -cvUf /tmp/tar.ar file1
    to build the gz enter gzip yourtar.tar
    Last edited by j2me64; 04-16-2010 at 11:37 AM.

  3. #3
    ashu_knw is offline Member
    Join Date
    Mar 2010
    Posts
    4
    Rep Power
    0

    Default

    Hi J2me64,

    Thanks for the response.

    But i need to do this through code in java lanuage.
    i want some java code example to achieve this.

  4. #4
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by ashu_knw View Post
    But i need to do this through code in java lanuage. i want some java code example to achieve this.

    then google for java TarArchive and you will find a bunch of sources.

Similar Threads

  1. Probelm reading text file from unix
    By manik in forum Networking
    Replies: 2
    Last Post: 12-24-2009, 08:28 AM
  2. Create an executeable file for java
    By cowboy in forum New To Java
    Replies: 14
    Last Post: 11-04-2009, 12:30 AM
  3. Replies: 5
    Last Post: 08-25-2009, 09:43 AM
  4. How to create exe file in java
    By radix in forum New To Java
    Replies: 8
    Last Post: 11-06-2008, 05:17 PM
  5. Filter a file in java (unix cut command equivalent)
    By marcosabel in forum New To Java
    Replies: 0
    Last Post: 02-11-2008, 08:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •