我从 X 站点下载所有 gz 格式文件。当我精确到 0KB 时,将所有文件下载到 temp 文件夹后。请帮助我解决代码注释。代码中的任何更改
URL site = new URL (sb.toString());
URLConnection uc = site.openConnection();
uc.setRequestProperty("Accept-Encoding", "gzip");//Here the change
java.io.BufferedInputStream in = new BufferedInputStream(uc.getInputStream());
//ZipInputStream gzin = new ZipInputStream(in);
GZIPInputStream gzin = new GZIPInputStream(in);
fileName = fileName.substring(fileName.lastIndexOf("/")+1);
File destFile = new File("D:\\source\\"+fileName);
java.io.FileOutputStream fos = new FileOutputStream(destFile);
GZIPOutputStream gz = new GZIPOutputStream(fos);
byte data[] = new byte[65536];
int gsize = 0;
while((gsize = gzin.read(data)) != -1)
{
gz.write(data, 0, gsize);
}