Reading a tar/bzip2 file.

Is there any way can I read, maybe a stream, a file in tar and bzip2 form(.tar.bz2)?

First you need to read the bzip2 format
[http://www.google.co.uk/search?q=bzip2+java]
into something which can read tar format
[http://www.google.co.uk/search?q=tar+java]

Similar Messages

  • Reading contents of tar.gz file programatically

    Hi,
    I have a file explorer type application, where I want the user to be able to double click on the tar.gz file and see the contents of the tar archive inside the .gz file.
    Of course, we dont want to have to extract the entire .gz file first. But it seems that the only way to read a .gz file is to use GZIPInputStream and if we through that, we will end up extracting the entire file.
    So can anyone tell me how to go about doing this?

    Hi,
    yes you're right. It's quite tricky sometimes to get what you need from a GZip file.
    What I found out today worked greatly.
    First of all, you need to get Apache Ant and inside the ant.jar file you'll locate the TAR package under tools (org.apache.tools.tar)
    So:
    1) Create a GZIPInputStream from the file (java.util.zip.GZIPInputStream)
    2) read the file entirely, coping it using a FileOutputStream
    3) In point 2, you created a tar file, you can read it with TarInputStream in org.apache.tools.tar TarInputStream.
    4) Get the entry you look for with TarEntry using
    - TarInputStream ts = new TarInputStream(file);
    - while (true){
    TarEntry t = ts.getNextEntry();
    if (tgetName().equals("myEntry")){
    //use ts to read this entry
    ts.read (buffer, 0, buffer.length)
    5) You have the unpacked Gzip entry where you want. Enjoy!
    ZazzaZ

  • Where is the xsqlservlet_v9****.tar.gz file?

    I'm looking to install XSQL Servlet support on Oracle 8.1.7.
    I've just downloaded the latest XDK for Java, since technet
    states the XSQL Servlet components are included in it. After
    uncompressing the download and reviewing the included
    documentation, I expected to find a xsqlserlvet_v9_0_1_0.tar.gz
    file included somewhere in the directory structure. Nope, not
    there...so either:
    (1). The included docs are wrong/outdated - I'm looking
    at "Downloading and Installing the XSQL Servlet".
    (2). My expectation is wrong OR missing an important step.
    (3). I've downloaded the wrong file.
    Any ideas? Thanks.

    Another observation on the release notes included with the
    download...
    In reviewing the section "Software Included in the XSQL Servlet
    Distribution" of the "Oracle XSQL Pages and the XSQL Servlet"
    Release Notes, it mentions the following files:
    .\xsql\lib\xmlparserv2.jar
    .\xsql\lib\xsu12.jar
    .\xsql\lib\classes12.jar
    .\xsql\lib\sax2.jar
    I don't see the .\xsql\lib directory structure in what I
    downloaded??? I see xmlparserv2 and xsu12 in the ./lib
    directory, but classes12 and sax2 are no where to be found.
    I realize I can download classes12 and sax2 from elsewhere, but
    I still have this strange feeling that I'm missing something
    here...

  • How to un tar required file?

    Hello All,
    I used TAR backup as below.
    tar -cvf test01.tar /uo1/oracle/bin/java
    its created testo1.tar file.
    Now i wanted to untar or recovery only one file instaed of whole tar file.
    for e.g: i wanted to recovery only file under bin folder callled config.
    how to un tar file?
    Any help will be appreciated. Thanks
    D

    You can look inside the tar using the 't' command:
    tar tvf file.tar And you can untar only one file with:
    frits@gateway:~/download$ mkdir t
    frits@gateway:~/download$ cd t
    frits@gateway:~/download/t$ touch a
    frits@gateway:~/download/t$ touch b
    frits@gateway:~/download/t$ tar czf ab.tgz *
    frits@gateway:~/download/t$ ls
    a  ab.tgz  b
    frits@gateway:~/download/t$ tar tzf ab.tgz
    a
    b
    frits@gateway:~/download/t$ rm a
    frits@gateway:~/download/t$ ls
    ab.tgz  b
    frits@gateway:~/download/t$ tar xzf ab.tgz a
    frits@gateway:~/download/t$ ls
    a  ab.tgz  b
    frits@gateway:~/download/t$

  • Extract A tar.gz file

    Ok guys,
    I have a program that extracts the contents of a tar.gz file. Right now it does extract one of the files and then throws an error:
    com.ice.tar.InvalidHeaderException: bad header in block 9 record 10, header magi
    c is not 'ustar' or unix-style zeros, it is '1141115144674854', or (dec) 114, 11
    1, 51, 44, 67, 48, 54
            at com.ice.tar.TarInputStream.getNextEntry(Unknown Source)
            at Extract_TAR_GZ_FILE.untar(Extract_TAR_GZ_FILE.java:37)
            at Extract_TAR_GZ_FILE.run(Extract_TAR_GZ_FILE.java:55)
            at Extract_TAR_GZ_FILE.main(Extract_TAR_GZ_FILE.java:67)
    bad header in block 9 record 10, header magic is not 'ustar' or unix-style zeros
    , it is '1141115144674854', or (dec) 114, 111, 51, 44, 67, 48, 54 The class that extracts the files:
    import java.io.*;
    import com.ice.tar.*;
    import javax.activation.*;
    import java.util.zip.GZIPInputStream;
    public class Extract_TAR_GZ_FILE {
         public static InputStream getInputStream(String tarFileName) throws Exception{
          if(tarFileName.substring(tarFileName.lastIndexOf(".") + 1, tarFileName.lastIndexOf(".") + 3).equalsIgnoreCase("gz")){
             System.out.println("Creating an GZIPInputStream for the file");
             return new GZIPInputStream(new FileInputStream(new File(tarFileName)));
          }else{
             System.out.println("Creating an InputStream for the file");
             return new FileInputStream(new File(tarFileName));
         private static void untar(InputStream in, String untarDir) throws IOException {
           System.out.println("Reading TarInputStream... (using classes from http://www.trustice.com/java/tar/)");
          TarInputStream tin = new TarInputStream(in);
          TarEntry tarEntry = tin.getNextEntry();
          if(new File(untarDir).exists()){
               while (tarEntry != null){
                  File destPath = new File(untarDir + File.separatorChar + tarEntry.getName());
                  System.out.println("Processing " + destPath.getAbsoluteFile());
                  if(!tarEntry.isDirectory()){
                     FileOutputStream fout = new FileOutputStream(destPath);
                     tin.copyEntryContents(fout);
                     fout.close();
                  }else{
                     destPath.mkdir();
                  tarEntry = tin.getNextEntry();
               tin.close();
          }else{
             System.out.println("That destination directory doesn't exist! " + untarDir);
         private void run(){
              try {               
                   String strSourceFile = "G:/source/BROKERH_20080303_A2008_S0039.TAR.GZ";
                   String strDest = "G:/source/Extracted Files";
                   InputStream in = getInputStream(strSourceFile);
                   untar(in, strDest);          
              }catch(Exception e) {
                   e.printStackTrace();          
                   System.out.println(e.getMessage());
         public static void main(String[] strArgs) throws IOException{
              new Extract_TAR_GZ_FILE().run();
    }The file I tested with can be found here:
    http://www.yourfilehost.com/media.php?cat=other&file=BROKERH_20080303_A2008_S0039.TAR.GZ
    Any help? Thanks a bunch.

    I fixed the problem. It was the ftp transfer of files program which wasn't set to BINARY mode. I edited that program and then rerun the above class and boom.. It worked.
    Thank you guys for responses.Great! Glad you got it working.
    ~

  • Downloading .tar.bz2 files ...

    ... why in **** does Safari add another .tar to .tar.bz2 files, and how do I stop it? Many thanks for the person who knows this one.
    -peter

    Hi,
    It's probably due to the mime encoding specified on the server side - Safari tends to believe what it's told.
    Assuming you're getting the file from wireshark.org, that download is reported as 'Content-Type: application/x-tar'
    (Compare that to the gzipped tar file there which is correctly defined as 'application/x-gzip')

  • Extracting tar.bz2 files.

    How can i extract tar.bz2 files?. zip, jar, tar can be extracted within java. But how tar.bz2?.

    Some tars have built-in knowledge of the bz2 (bunzip) compression format.
    Tar ("tape archive") is to package several files in one archive or to extract them. The archive files can be called "*.tar".

  • Client to unzip tar.gz file on remote webserver

    I'm not sure if this is the right place to post my question - sorry.
    I was wondering if there is a mac client program to assist in unzipping a tar.gz file on a remote web server.
    I know that it can be done using putty, but was hoping that there might be a "cleaner and more usable" solution.
    TIA
    -jP

    Mac has a build-in unzipper.
    Just double-click the file.
    In case itt does not expand, select the file and type Cmd-I.
    Then at +Open with,+ navigate to:
    /System/Library/CoreServices/
    and choose BOMArchiveHelper
    Click +Always open with this application+.
    There's more on the internet [unzip .gz osx|http://www.google.com/search?q=unzip%20.gz%20os%20x]

  • Extract multiple tar.gz files

    hey people
    I.ve got a problem here. I.ve got a folder with about 100 .tar.gz files, and I want to extract them all with 1 command. How do I do this? "tar zxvf *.tar.gz" doesn.t work...
    cheers

    find . -name "*.tar.gz" -exec tar xvzf {} ;

  • Automatically decompress *.tar.gz files to *.tar within Windows 2008 R2 Enterprise?

    Is it possible to have any and all *.tar.gz files that are dumped to a certain folder automatically decompressed/unzipped to *.tar in order to be processed by an sFTP job?  Thanks for any help you may be able to provide.

    Hi Señor SIEM,
    If you want to unzip files in powershell, this needs the thrid-party unzip application to run the powershell script, for more detailed information, please refer to this thread:
    powersell How to Unzip a file and copy it to specific location with 7zip?
    I hope this helps.

  • Automator workflow to TAR multiple files in a single directory into multiple TAR archives, in succession?

    Good afternoon,
    I have set up an automator service that TAR's a folder into an archive for me and it works quite nicely. Idealy however, I would like to be able to highlight several folders, right click and have automator tar each folder into it's own TAR archive, but do it one by one.
    Example:
    FOLDER 01
    FOLDER 02
    FOLDER 03
    Highlight all - Right Click - "TAR Folder" - Automator takes over at this point and TARs each one into:
    FOLDER 01.tar (Once complete moves onto:)
    FOLDER 02.tar (Once complete moves onto:)
    FOLDER 03.tar (Finished)
    I'm not 100% sure so I guess it would be a good time to verify, is there a problem with having the system try to TAR multiple folders at one time? If it is not a problem then I guess this discussion itself is pointless and I can simple right click on each folder and select "TAR Folder" and just wait until they're all finished. I would think that it would be ideal for the system to do each one individually and not try to do them all at one time.
    Any help would be appreciated.
    Thank you!!

    I don't think I have the following totally fleshed out but you probably can extrapolate on it.   This is a service which you can right click a set of folders  and it will tar the files within those selected folders with then file names "name xxx.tar", where name is the tar'ed file/folder and xxx is a count within the folder.
    I think that is what you originally specified so I am a bit confused by your script with the bit about Archive.tar. 
    Anyway here the basic idea:
    I ran the script directly with a folder argument just to see it indeed tar's up all the stuff inside, one tar per item.

  • BomArchiver not working anymore for tar.gz files

    I don't know what happened to my system, but I can't expand tar.gz files anymore using BomArchiver. The "Expand window" flashes half a second and disappears.
    I check all Permissions but no chance.
    Then i opened a terminal window pointing to the gzip file and discovered that, each time i try to unzip the file, a new invisible folder, name .BAHxxxx (where xxxx is a random number) containing an invalid file. Group for that folder is wheel with Read Only.
    Any help ?

    Yes, at the moment 14 people have read your message but evidently no one, including me, actually knows the nature of the problem, let alone a solution. If you have Console (it is in your Utilities folder) running in the background, does it show an error message when the failure occurs?
    Francine
    Francine
    Schwieder

  • Uncompress tar.z file

    Hello,
    I am writing code to take an tar.z file and process it. I tried to use the clases in java.util.zip but it is not working. My code can uncompress a file that is zipped in winzip and untar a .tar file but throws a ZipException with I try a tar.z. I am thinking that .z is compressed in unix differently that winzip or a normal .zip file. If anyones has run into this situation before any advice would be greatly appreciated.

    'z' files are created by the 'compress' program which is often in the ncompress package. From the man pages:
    Compress uses the modified Lempel-Ziv algorithm popularized in "A Technique for High Performance Data Compression", Terry A. Welch,
    IEEE Computer, vol. 17, no. 6 (June 1984), pp. 8-19.
    If you have a *nix box lying around, do a "file" to determine if its "compress'd" data, or better yet, try "uncompress" to inflate the data.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Windows Easy Transfer (WET) Issues with External Hard Drive - "Can't read from the source file or disk"

    I work for Office Depot, in the tech department. Basically, one of our associates was supposed to do a data backup, and re-install Windows 7, then transfer the files back. He used Windows Easy Transfer and compacted everything into a 163 GB file. 
    Now comes the hard part. When we try to put it back on his computer ((drag-and-drop to the desktop) which has been wiped back to factory settings using the recovery partition), it stops at 79.5 GB remaining (you know how it doesn't give you a % of completion,
    it just shows how many GB are remaining) and then says "Can't read from the source file or disk" and gives you an option to try again, or cancel. It gets hung up on the same point each time.
    Normally, this wouldn't be a huge issue, but the contents on the drive are his wife's architect blueprints and interior design stuff, along with wedding photos, etc, which are the only copies they have. On top of those, they have court documents and other
    important files that we are unable to access now.
    I wasn't involved with this transfer, so I'm trying to clean up the mess as best I can. I remembered that the customer's wife was Russian, and had some files typed with a Russian keyboard, so on and so forth. I wonder if that's the issue? If not, I really
    have no idea how to manually extract things from a ".mig" file, or how to diagnose what area is potentially corrupted.
    In light of this situation, we tried using "Recuva" to recover the files post-wipe, but everything was corrupted or unable to be opened, and it also extracted and recovered all of the "useless" photos, such as the skype logos, up and
    down arrows for browsers, etc (it was 160,000+ photos).
    Trying to avoid a potential lawsuit, unhappy customer, and costing the company lots of money to see if professionals can get into this external hard drive.
    Other relevant information:
    We used a Toshiba 500 GB (465 GB) external hard drive.
    Customer's computer is an HP Pavilion P6000 Series (Model No. p6520y) running Windows 7 Home Premium 64-bit Service Pack 1.
    Any other information that is needed can be provided, thanks in advance, and hopefully we can find a solution to this issue quickly!
    -John

    I think there's a lack of understanding somewhere.
    "If you even can't start the process, please unplug it from your new PC. Then head back to your new computer and plug
    the external drive back in to your new computer. "
    Unplug from new, head back to new, plug it back in? That doesn't make much sense! Haha.
    I knew what you meant though, somewhat. When I search through the drives after clicking yes (Has windows easy transfer
    already saved your files blah blah blah) I click on the transfer file and it says "Windows Easy Transfer could not open the file".
    Rather than drag-and-drop the file to the desktop, I now tried to double-click on the file itself while it was plugged
    into the computer. It opened, and it started transferring until it was about 70% completed, and then an error popped up saying "WET can't open the easy transfer file, make sure your USB device is plugged in or check your internet connection". 
    I checked, and the USB hard drive's light wasn't on. Now, I unplug it and plug it back in, and the light comes back on,
    so I click Retry, and it resets the bar back to nothing and says "Transfer time: 1 minute".
    Rather than continue trying, I clicked "Cancel" instead of Retry, and it says "Your transfer did not complete successfully."
    It says to click "view report" for more information, but there's no "view report button".
    At the moment, I am scanning the External Drive for bad sectors using the check disk tool in properties. It's frozen
    at "0 USN bytes processed".

  • Can't read or write some files, internet is failing, youtube won't load, software I tried to install was in Slovenian, not dutch or english like in my systempreferences settings, pictures and files won't preview with spacebar, etc. Malware?

    Specs:
    iMac 10.8.5
    3,4 GHz Intel Core i7
    32 GB 1600 MHz DDR3
    Can't read or write some files, internet is failing, youtube won't load, security software I tried to install was in Slovenian, not dutch or english like in my systempreferences settings, pictures and files won't preview with spacebar and are randomly corrupted, when I entered something in the Youtube searchbar (when it was still working) it send me to a site with sexadds.
    I tried restart my iMac and when I was logged back in, my dock preferences were reset.
    Also tried to download some security software to check my Mac for malware, but when I did, I tried several, I got a notification that said something like 'dumpfiles (don't know if this is the right translation...) damaged'.
    I'm taking screenshots from all the weird notifications I get and even three quarters off the screenshots I took in the last three hours are already unreadable.
    It started this morning when I tried opening a Premiere Pro file on which I worked the night before.
    When I tried opening it, it said the file was damaged and could not be openend.
    I tried opening it with AE or importing the file in a new project but nothing helped.
    When I tried looking for autosaves, this is the really weird part, there were none.
    Even though there are autosaves from my other projects, this one was completely gone.
    It looked like the day before never happened on my computer.
    Also when I openend Premiere all the recent projects had been wiped.
    So at first I thought it was a Premiere Pro failure.
    But than, later on the day, I tried loading some RAW files from my compact flash card.
    This is where I would get an error (error -36) which said some data cannot be read or written.
    I tried importing the files with a view different technics, from dragging to importing via Lightroom and I succeeded with Image Browser.
    But when I tried moving the files to an other folder the same error occurred.
    While dealing with this issue I wanted to put on some soothing music on youtube.
    This is when the next weird thing occurred: youtube wasn't completely loading in Chrome. I refreshed a view times, checked the internet connection and still no difference.
    When I tried in Safari it did work but when I clicked enter on the searchbar in Youtube, a page with sexadds appeared (I didn't install AdBlock in Safari...).
    I read about this 'phishing' where you are redirected to a site were a possible malware installment can take place...
    I don't know if it's connected to any of the problems I've been having but I just never experienced this on a mac, I have been a Mac user for 10 years now.
    On top of it all, internet started working worse and worse and now it's not even working at all. I had to fill in the password over and over, normally it remembers.
    Just like my system preferences, all the preferences I had with Chrome where also reset.
    Also somewhere in between I got this notification: Mac OS X must restore library to run programs. Type your password to allow.
    To me this is all very weird and suspicious. I have clearly no idea what's going on. Could this be another sort of trojan horse or malware?
    Some background info which could be helpful for solving this mystery:
    two months ago the one year old Fusion Drive in my iMac just broke out of nowhere.
    I got it replaced by a qualified apple repair store.
    When I got my computer back, all the files where gone.
    I got on the internet without AdBlock installed yet.
    A game or whatever it was, can't clearly remember, got installed by accident.
    I deleted it immediately.
    Only two weeks later, I couldn't log in to my account. It didn't recognize my password and username. 
    So I brought my mac back to the store.
    Here the repair guy said it was a minor thing and he just needed to reconnect my account. He also mentioned he found a downloaded game name Sparta and it probably had something to do with the error.
    I asked him; could it be a virus? He replied no way.
    I don't know why I couldn't be a virus, just because it's a mac doesn't mean it cannot be done.
    So today I tried installing anti virus software (such as avast- was in a weird language looked like slovenian, clamxav - was in slovenian) but I couldn't install them.
    PLEASE help me! I don't know what to do anymore, I work fulltime and I need my computer, I have no time to bring it in for repair, are there other perhaps easier ways?
    Could this be the work of a virus or a malware? Or is it a disk permissions issue?

    It sounds like you may have multiple problems, but none of them are likely to be caused by malware.
    First, the internet-related issues may be related to adware or a network compromise. I tend to lean more towards the latter, based on your description of the problem. See:
    http://www.adwaremedic.com/kb/baddns.php
    http://www.adwaremedic.com/kb/hackedrouter.php
    If investigation shows that this is not a network-specific issue, then it's probably adware. See my Adware Removal Guide for help finding and removing it. Note that you mention AdBlock as if it should have prevented this, but it's important to understand that ad blockers do not protect you against adware in any way. Neither would any kind of anti-virus software, which often doesn't detect adware.
    As for the other issues, it sounds like you've got some serious corruption. I would be inclined to say it sounds like a failing drive, except it sounds like you just got it replaced. How did you get all your files back after the new drive was installed?
    (Fair disclosure: I may receive compensation from links to my sites, TheSafeMac.com and AdwareMedic.com, in the form of buttons allowing for donations. Donations are not required to use my site or software.)

Maybe you are looking for

  • Need help in creating logic

    Hi all, I need suggestion of all of you guys in approaching my goal. What i want to do is... I have a bow still at one place but can rotate at its pivot point and there is an arrow that is used to pull the thread of the bow, as i drag back the arrow

  • Mac Mini Display

    I have a newer 20'' Memorex LCD TV. It can be used specifically for a monitor because there is a PC channel and it is also inteded in the manual. I just ordered my Min yesterday and ive been reading that there has been a few issues with LCD tv's and

  • HDMI & Bluetooth Issues on RAZR

    My RAZR recently detects an HDMI connection and prompts me every time i unlock my device to choose what to do next. Of course, there is no HDMI cable and i have never connected a HDMI cable. Also, my bluetooth wont connect. It doesnt even turn on. It

  • Visual Studio 2008 Toolbox - i can use crystal reposts 2008

    Hi I have a strange problem. I reintall my machine with a new copy of windows vista 32 bits, then I install the visual studio 2008 Pro (not install de crystal reports basic). Then I install de crystal reports 2008. In the vs2008 toolbox donu2019t app

  • Safari will no longer load any images in the browser. What could be the problem?

    In the last couple of months safari will no longer load any type of image in the browser. All the text loads fine and the layout is correct but everywhere there should be a picture of any sort is blank. what can I do to fix this?