//zip数据处理 public List<Map<String,Object>> readZipFile(String file,ChironUser user) throws Exception { //ZipFile zf = new ZipFile(file); int i=0; List<Map<String,Object>> list=new ArrayList<Map<String,Object>>(); URL url = new URL(file); URLConnection connection = url.openConnection(); InputStream in = connection.getInputStream();//new BufferedInputStream(new FileInputStream(file)); ZipInputStream zin = new ZipInputStream(in); ZipEntry ze; while ((ze = zin.getNextEntry()) != null) { Integer fail=0; String msg=""; if (ze.isDirectory()) { } else { i++; ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream(); byte[] byte_s=new byte[1024]; int num=-1; while((num=zin.read(byte_s,0,byte_s.length))>-1){//通过read方法来读取文件内容 byteArrayOutputStream.write(byte_s,0,num); } byte[] byte_s_=byteArrayOutputStream.toByteArray(); Map<String,Object> m=new HashedMap(); //可以不要------ if(ze.getName().substring(ze.getName().indexOf(".")).equals(".png") || ze.getName().substring(ze.getName().indexOf(".")).equals(".jpg") || ze.getName().substring(ze.getName().indexOf(".")).equals(".gif") || ze.getName().substring(ze.getName().indexOf(".")).equals(".bmp") || ze.getName().substring(ze.getName().indexOf(".")).equals(".jpeg")){ if(ze.getName() != null){ if(getStudentCot(user,ze.getName().substring(3,ze.getName().indexOf(".")))==0){ if(user.getTypeId().equals(10003)){ fail++; msg += "<br/>错误:行" + i + " :您不是该学生的辅导员"; }else { fail++; msg += "<br/>错误:行" + i + " :未找到该学生或该学生没有辅导员"; } } }else { fail++; msg += "<br/>错误:行" + i + " :未找到该学生"; } }else { fail++; msg += "<br/>错误:行" + i + " :只支持 png , jpg , gif , bmp , jpeg格式图片上传"; } //-----可以不要 到这 m.put("fail",fail); m.put("msg",msg); m.put("idCode",ze.getName()); m.put("bytes",byte_s_);//压缩包中的单个byte list.add(m); //String fileNeirong=new String(byte_s,"UTF-8");//将字节数组转化为字符串,UTF-8格式(容许中文) //System.out.println(fileNeirong); } } zin.closeEntry(); return list; }