把文件打包到压缩包里

public void zip (String... files) throws IOException {
  //创建文件打包流对象 ZipOutputStream zos
= new ZipOutputStream(new FileOutputStream("d:\\eee.zip")); for (String file : files) {
    //内容描述 ZipEntry zipEntry
= new ZipEntry(file); zos.putNextEntry(zipEntry);      
    
     //创建文件输入流 FileInputStream fis
= new FileInputStream(file); int c; while ((c = fis.read()) > 0) { zos.write(c); } fis.close(); } zos.close(); }

 

相关文章:

  • 2021-11-12
  • 2022-12-23
  • 2022-01-11
  • 2021-08-27
  • 2021-05-24
  • 2022-02-17
  • 2021-08-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
  • 2021-07-13
  • 2021-11-27
  • 2021-07-17
  • 2021-12-01
相关资源
相似解决方案