首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

关于使用JAVA.util.zip压缩文件后,解压缩时出现文件名乱码的解决方法

2012-11-07 
关于使用JAVA.util.zip压缩文件后,解压缩时出现文件名乱码的解决办法//使用org.apache.tools.zip包public

关于使用JAVA.util.zip压缩文件后,解压缩时出现文件名乱码的解决办法

//使用org.apache.tools.zip包  public void ExportRARTest(String tablename[],HttpServletRequest request,String dir,String fileFolder,String isback) throws IOException{   byte[] buf = new byte[1024];       org.apache.tools.zip.ZipOutputStream out = new org.apache.tools.zip.ZipOutputStream(new FileOutputStream(dir));       String pathString="";       if ("yes".equals(isback)) {pathString=fileString+fileFolder;}       else {pathString=request.getRealPath("/")+"updbload";}       try {       for(int i=0;i<tablename.length;i++) {       tablename[i]=pathString+"/"+tablename[i];       File file=new File(tablename[i]);       if (file.exists()) {           FileInputStream fis = new FileInputStream(file);           out.putNextEntry(new org.apache.tools.zip.ZipEntry(file.getName()));           int len;           //读入需要下载的文件的内容,打包到zip文件          while((len = fis.read(buf))>0) {           out.write(buf,0,len);           }           out.closeEntry();           fis.close();           file.delete();       }       }} catch (Exception e) {// TODO: handle exceptione.printStackTrace();}      finally{        out.close();      }}注意黑体<Strong></Strong>部分是解决中文乱码的关键!!!!!!

?

热点排行