标签:top new tor write min str ips file rect
一段 java zip 压缩的代码
File dir = new File("C:\\Users\\Administrator\\Desktop\\zipsource"); String zipFile = "C:\\Users\\Administrator\\Desktop\\test2.zip"; OutputStream outputStream = new FileOutputStream(new File(zipFile)); ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream); byte[] buffer = new byte[1024]; int len = 0; if( dir.isDirectory() ) { File[] files = dir.listFiles(); for(File fileItem :files) { FileInputStream fileItemInputStream = new FileInputStream( fileItem ); ZipEntry zipEntry = new ZipEntry( fileItem.getName() ); zipOutputStream.putNextEntry( zipEntry ); while( (len = IOUtils.read(fileItemInputStream, buffer)) != 0 ) { zipOutputStream.write( buffer,0,len ); } fileItemInputStream.close(); } } zipOutputStream.flush(); zipOutputStream.close();
标签:top new tor write min str ips file rect
原文地址:https://www.cnblogs.com/cxygg/p/9448166.html