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:
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)) >= 0) {
out.write(bytesIn, 0, i);
}
out.close();
in.close();
}
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.
When I download this file manually, it unzips and everything perfectly fine, so I know it isn't a problem with the file.
Any suggestions would be greatly appreciated! Thank you so much!
When I print out the contents of the file you download it appears as
-r--r--r-- 1 ftp anonymous 2311751 Jan 29 16:45 GSE10_family.soft.gz
If I download the file instead of the directory I get a gzip file.
$ gunzip GSE10_family.soft.gz
$ ls -l GSE10_family.soft
----------+ 1 peter None 7698802 2011-06-09 16:24 GSE10_family.soft
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With