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
If I download the file instead of the directory I get a gzip file.