当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
Java删除文件和删除文件
发布时间:2010/9/21 11:18:49 来源:城市学习网 编辑:ziteng
  private void deleteFiles(List<String> fileList, String path) {
  for (int index = 0; index < fileList.size(); index++) {
  String fullName = path + fileList.get(index);
  File file = new File(fullName);
  if (file.isFile() && file.exists()) {
  file.delete();
  }
  }
  }
  private void zipFile(List<String> fileList, String path, String zipFN) throws IOException {
  FileOutputStream fileOut = new FileOutputStream(path + zipFN);
  ZipOutputStream outputStream = new ZipOutputStream(fileOut);
  for (int index = 0; index < fileList.size(); index++) {
  String fileName = fileList.get(index);// "StockValuation.xls";
  String fullName = path + fileName;
  FileInputStream fileIn = new FileInputStream(fullName);
  ZipEntry entry = new ZipEntry(fileName);
  outputStream.putNextEntry(entry);
  byte[] buffer = new byte[1024];
  while (fileIn.read(buffer) != -1) {
  outputStream.write(buffer);
  }
  outputStream.closeEntry();
  fileIn.close();
  }
  outputStream.close();
  fileOut.close();
  }
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved