Write program to download .gz file in java?
<p>I've been trying to write a program in java that can download a number of .gz files from an ftp server online for me. Here's what I've been using:</p>

<pre><code>public static void main(String[] args) throws IOException {
    URL url = new URL("ftp://ftp.ncbi.nih.gov/pub/geo/DATA/SOFT/by_series/GSE10/");
    URLConnection con = url.openConnection();
    BufferedInputStream in = new BufferedInputStream(con.getInputStream());
    FileOutputStream out = new FileOutputStream("GSE10_family.soft.gz");

    int i = 0;
    byte[] bytesIn = new byte[3000000];
    while ((i = in.read(bytesIn)) &gt;= 0) {
        out.write(bytesIn, 0, i);
    }
    out.close();
    in.close();

}
</code></pre>

<p>The program runs and downloads the file just fine. However, when I try to uncompress the .gz file, it unzips as a .cpgz file which then creates an endless cycle of .cpgz to .gz and so forth.</p>

<p>When I download this file manually, it unzips and everything perfectly fine, so I know it isn't a problem with the file.</p>

<p>Any suggestions would be greatly appreciated! Thank you so much!</p>
