急求!winxp环境下将.xls文件压成.gzip包的 java代码!!急急急!要详细代码 能通过你自己验证的

2025-01-05 15:59:29
推荐回答(1个)
回答1:

public static void main(String[]str){
try{
String excelFile = "";
String gzipFile = "";
java.util.zip.GZIPOutputStream stream = new java.util.zip.GZIPOutputStream(new FileOutputStream(new File(gzipFile)));
java.io.FileInputStream fis = new java.io.FileInputStream(new File(excelFile));
byte[] buf = new byte[1024];
int len = 0;
while((len = fis.read(buf))>0){
stream.write(buf, 0, len);
}
stream.close();
}catch(Exception exp){
exp.printStackTrace(System.out);
}
}