我有一个zip文件叫aaa.zip,里面有几个文件,aaa.zip在d盘的new目录下,在d:\new目录下有两个文件a.txt,b.txt,现在要用java实现把a,b两个文件添加进aaa.zip的根目录下,且aaa.zip里的文件保留.
我研究几天了,请各位朋友帮助解决,提供解决的代码,备受感激!
我研究几天了,请各位朋友帮助解决,提供解决的代码,备受感激!
调试欢乐多
没用过。
楼上的说一下
CheckedOutputStream csum = new CheckedOutputStream(f, new Adler32());
ZipOutputStream Zipout = new ZipOutputStream(new BufferedOutputStream(csum));
String[] myfile = {"d:\\eeee\\question.txt"};
byte[] buffer = new byte[16384];
for(int i = 0; i < myfile.length; i++)
{
System.out.println("Writing file " + myfile[i]);
BufferedReader inic = new BufferedReader(new FileReader(myfile[i]));
ZipEntry zipe = new ZipEntry(myfile[i]);
Zipout.putNextEntry(zipe);
int count;
while ((count = inic.read())!= -1)
Zipout.write(count);
inic.close();
}
Zipout.close();
上面这段代码已能实现把一个文件放进zip里,但zip里的文件没了,且不是放在zip的根目录,哪位来改进一下啊