FileOutputStream fos = new FileOutputStream(desFile);
JarOutputStream jos = new JarOutputStream(fos);
FileInputStream fis = new FileInputStream(file[i]);
JarEntry entry = new JarEntry(file[i].getName());
//这一行,打包之后用WINRAR打开,文件名称如果是中文,就会出现乱码
entry.setMethod(JarEntry.DEFLATED);
jos.putNextEntry(entry);
int n = fis.read(buffer);
while(n != -1)
{
desLen+=n;
jos.write(buffer,0,n);
n=fis.read(buffer);
}
jos.flush();
fis.close();
JarOutputStream jos = new JarOutputStream(fos);
FileInputStream fis = new FileInputStream(file[i]);
JarEntry entry = new JarEntry(file[i].getName());
//这一行,打包之后用WINRAR打开,文件名称如果是中文,就会出现乱码
entry.setMethod(JarEntry.DEFLATED);
jos.putNextEntry(entry);
int n = fis.read(buffer);
while(n != -1)
{
desLen+=n;
jos.write(buffer,0,n);
n=fis.read(buffer);
}
jos.flush();
fis.close();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货