[求助]java.util.zip 可以这样写吗?
我想把inputfile 压缩成zipfilename ,请问各位高手可以这样写吗?//创建一个ZIP文件zipfilename ----- (xxx.zip)
File f = new File(zipfilename);
FileWriter fw = new FileWriter(f);
ZipOutputStream out = new ZipOutputStream(new BufferedWriter(fw));
//被压缩的文件inputfilename
FileReader in = new FileReader(new File(inputfilename));
BufferedReader br = new BufferedReader(in);
out.putNextEntry(new ZipEntry(inputfilename));
String c;
while ((c = br.readLine())!=null) {
out.write(c);
out.newLine();
}
in.close();
out.close();