Can't download .GZ file - incorrect file type?

Thank you for helping me. Using the code below, I am trying to access a log file from a site (log.gz) and download it to my hard drive to expand and analyze locally. When I try to expand the file, the message says that it does not recognize the file type. I suspect that it is adding in errant bits of data. Is there some way to make it keep the data structure intact?
Thanks,
Greg
import java.net.*;
import java.io.*;
import java.util.Date;
public class SaveWebFile{
public static void main(String[] args) {
     String username = "xxxx";
     String password = "xxxxx";
String authorization = username + ":" + password;
sun.misc.BASE64Encoder enCoder = new sun.misc.BASE64Encoder();
String encodedAuthorization = "Basic " + enCoder.encode(authorization.getBytes());
try{
     URL url = new URL("http://www.test.com/logs/dailylog.gz");
     HttpURLConnection con = (HttpURLConnection)url.openConnection();
     con.setRequestProperty("Authorization", encodedAuthorization);
     InputStreamReader in = new InputStreamReader (con.getInputStream());
     OutputStream out = new FileOutputStream( "c:\\logs\dailylog.gz" );
     int b;
     while( (b = in.read()) != -1) out.write( (byte)b );
     in.close();
     out.close();
     } catch (MalformedURLException e) {
     System.out.println (" is not a valid URL.");
     System.exit(1);
     } catch (IOException e) {
     System.out.println ("Unable to connect");
     System.exit(1);
}

Does this fix it?
BufferedInputStream in = new BufferedInputStream(con.getInputStream());
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("log.gz"));
final int NUM_BYTES = 32768;
int numBytesRead = 0;
byte[] buf = new byte[NUM_BYTES];
while( (numBytesRead = in.read(buf, 0, NUM_BYTES)) != -1)
  out.write(buf, 0, numBytesRead);
  out.flush();
out.close();
in.close();

Similar Messages

  • Can't download any file

    Hai iam using iPhone 5 and I can't download any file even a text please help me

    What type of files are you trying to download from the browser?,
    some types it will try to open instead of saving it and it will fail if it can't open it.
    640K Should be enough for everybody
    El_Loco Nokia Video Blog

  • Can't download any file... N70

    Hi...
    I can't download any file using integrated browser.
    Internet connection is OK - my ICQ and Opera mini work good. But when I want to download file Opera switchs off and integrated browset tries to download.. It connects....and that's all...nothing happens... What's the problem???
    P.S. Maybe some1 knows how to download files without integrated browser?
    P.P.S. I'm russian guy, so...my english may be not so good....

    What type of files are you trying to download from the browser?,
    some types it will try to open instead of saving it and it will fail if it can't open it.
    640K Should be enough for everybody
    El_Loco Nokia Video Blog

  • After downloading a file Type RAR

    After downloading a file Type RAR,,I always get the message "Do you want to use RarGenie to open this file type??"
    How can I get rid of this message?
    <Subject Edited by Host>

    Thanks Hosts.
    (Tidied title)
    9:14 pm      Wednesday; April 8, 2015
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • HT1420 my laptop has been stolen. I have bought a new one but I can't download the files (movies, articles,...) that I have in my ipad into my new ipad so I can put some of them in my daughters mini ipad. How can i do it?

    My laptop has been stole. I have bought a new one but I can't download the files (homemovies, articles, presentations) from my ipad to the new laptop so I can share with my daughters in their mini ipads. Any ideas?
    I am working with Windows 8

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • Can I download a file in different sessions or should it be in a single session? In other words can I pause the download of a file, shutdown/restart my system and then resume download from where I left off? Or will it start from the very beginning?

    Can I download a file in different sessions or should it be in a single session? In other words can I pause the download of a file, shutdown/restart my system and then resume download from where I left off? Or will it start from the very beginning?

    If a server supports resuming downloads then the download should continue where it left off.<br />
    You can test that by simple starting a large download and wait a minute or so before pausing it.<br />
    Then you can close and restart Firefox and see if resuming works.
    You can set the pref browser.download.manager.quitBehavior to 2 on the about:config page.<br />
    That will make Firefox ask for confirmation if you want to cancel the download if you close Firefox.
    See:
    * http://kb.mozillazine.org/browser.download.manager.quitBehavior

  • Where can I download adobe File Packager tool for Windows?

    Dear all,
    I need to understand the detail format of f4f files, but the only useful information I can find is the following:
    http://www.adobe.com/products/httpdynamicstreaming/pdfs/httpdynamicstreaming_wp_ue.pdf
    Is there more detail specification for f4f ?
    Where can I download adobe File Packager tool for Windows?
    It seems to me the following specification is not correct for f4f, at least the parts talking about "mdat" box
    http://download.macromedia.com/f4v/video_file_format_spec_v10_1.pdf
    Thanks,
    Xuedong

    As per your question – follow this link http://www.adobe.com/products/adobe-media-server-family.html, download and install AMS Starter, then inside \tools\f4fpackager you’d find the F4F packager command-line application.

  • I can not download any files using Safari ? when I choose to download application file the URL include the file name and stop responding. Any help??

    I can not download any files using Safari ? when I choose to download application file the URL include the file name and stop responding. Any help??

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up a guest account” (without the quotes) in the search box.
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem(s)?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault in Mac OS X 10.7 or later, then you can’t enable the Guest account. The Guest login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:
    Be sure your Mac is shut down.
    Press the power button.
    Immediately after you hear the startup tone, hold the Shift key. The Shift key should be held as soon as possible after the startup tone, but not before the tone.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    *Note: If FileVault is enabled under Mac OS X 10.7 or later, you can’t boot in safe mode.
    Test while in safe mode. Same problem(s)?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • Will a program mention for MAC OSX be allowed to download on the newest iPad version. If so, how do I get past the "safari" can not download this file?

    Will a program mention for MAC OSX be allowed to download on the newest iPad version. If so, how do I get past the "safari" can not download this file?

    No, because iPads do not run Mac OS X. They run iOS.

  • I can't download ANY file with Safari 5.1

    Hello, I need hel please.
    The problem I have is the following:
    Safari 5.1 can't download ANY file. I have a Macbook pro running on 10.7.2
    I think the problem started after upgrading to Lion. The only way I manage to download files is "right clicking" the file and selecting the download button from there. I can't do this with all of the downloads because lots of internet downloads redirects users to another page which says, for example,  "your download will start in a few seconds" and with the problem I have, it never starts. The page remains like it's loading but I leave it there for a while and download don't start.
    I tried with Chrome and the problem is there as well.
    Any help will be great,
    Thanks

    Forgive me in case this is obvious to you, but since you say you just upgraded to lion, it may apply.
    When you download the only indication you get is a blue progress line in the small down arrow download icon on the top/right side of the Safari window, next to the Search box. Click on that and you'll see a list of recent downloads assuming it's working.
    I assume you've used Finder to look in your Downloads folder for the files already.

  • I've up graded my Canon 5D Mk1 to a Mk3.  now I can't download RAW files as veiwable thumbnails

    I've up graded my Canon 5D Mk1 to a Mk3.  now I can't download RAW files as veiwable thumbnails via CS4 Photodownloader only as 'tiles'.  I can still double click these tiles and open in PS elements and edit OK.  But they remain as tiles after editing although the resulting Jpeg can be seen as thumbnail in folder although needs purging first.  Please help.

    Run Help> Updates to get v8.3 of the Camera RAW Plug-In.
    Cheers,
    Neale
    Insanity is hereditary, you get it from your children
    If this post or another user's post resolves the original issue, please mark the posts as correct and/or helpful accordingly. This helps other users with similar trouble get answers to their questions quicker. Thanks.

  • I can't download linked files on mac osx lion what do i do?

    i can't download linked files on mac osx lion what do i do?

    There have been some reported problems with Apple's servers.
    Try this.
    Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.)
    Go to Settings>Wi-Fi and turn Off. Then while at Settings>Wi-Fi, turn back On and chose a Network.
    I assume you are trying to update via wifi. You can also connect the iPad to your computer and update using iTunes.
     Cheers, Tom

  • All the links to download DREAMWEAVER CS3 Creative Suite are not working. How can I download the file ? I have a serial number of a purchased software.

    All the links to download DREAMWEAVER CS3 Creative Suite are not working. How can I download the file ? I have a serial number of a purchased software.

    They work just fine. whatever issues you have are specific, but without proper system info, browser info and other details nobody can even begin to guess.
    Mylenium

  • I want to re-install Premiere Elelments 8, but cannot find downloads for version 8.  Where can I download the files for version 8?

    I want to re-install Premiere Elelments 8, but cannot find downloads for version 8.  I have the serial no.  Where can I download the files for version 8?

    Hi Jeff.  I did purchase Premiere Elements 8 from Adobe (download version), but couldn't find the files to download again on the adobe.com website.  I did, however carry out another search of files from my old PC and eventually found the files to reinstall on my new PC, using my registered product serial no.  Installation has worked.  It seems that Adobe has stopped supporting version 8 as I could only find version 9 and later for download from the adobe.com website.
    Thanks for your prompt reply

  • New iMac running 10.8.3 and Safari 6.0.3. Can't download most files--even pdf. Get a full black screen and no download. Will download same undownloadable files if I use FireFox. Any help?

    New iMac running 10.8.3 and Safari 6.0.3. Can't download most files (even pdf) or applications. Get a full black screen and no download. Can successfully download the same files using FireFox. Have tried all the usual stuff--resetting Safari, etc. Any help?

    From the Safari menu bar, select
    Help ▹ Installed Plug-ins
    Besides the following, what plugins are listed?
    iPhotoPhotocast
    Java
    QuickTime
    Shockwave Flash
    WebKit built-in PDF

  • I just bought the nikon d600 and i can't download raw files?

    I just bought the nikon D600 i can't download raw files into LR4?

    http://forums.adobe.com/community/search.jspa?peopleEnabled=true&userID=&spotlight=false&c ontainerType=14&container=3316&rankBy=date&q=d600

Maybe you are looking for

  • How can you display all the messages in a thread, showing the original message on top instead of at the bottom?

    I want to print an email conversation and the thread is pretty long. I want to print the conversation showing the original message first, and the last reply last, so that it reads like a book and not backwards.

  • Final Cut Pro X share operation failed

    Recent error message when sharing to custom compressor settings stating Share operation [project name] Failed (com.apple.Compressor.CompressorKit.ErrorDomain error -1.). Unsure why 30sec 720 x 576, 16:9 won't share to custom settings 1024 x 576, 1:1.

  • Can't export in iPhoto 2.0.1

    Help! I can't export my photos. I select them all, click on export and I get an error saying: "There is not enough disk space to complete that operation." I have 56 GB free and it'll only do a few at a time. Can anyone shed any light on this?   Mac O

  • IPhone 5s and MacBook Pro mid 2012 Bluetooth

    Hi, I was wondering if there is anyone who would offer any help to the issue I'm facing. I'm an owner of the following devices: iPhone 5s running iOS 8.0.2 MacBook Pro mid 2012 running Yosemite I tried connecting/pairing both devices via Bluetooth to

  • "Logging level" - what exactly is logged at a given level?

    Wanting to log activity from an Airport Express I have been searching for a list of which types of events actually are logged depending on the "Logging level" selected in the "Airport Admin Utility" software at the "Airport" tab, "Base Station Option