我正在创建一个 .csv 文件,它是在指定的位置创建的,现在我想将该文件压缩到同一位置,所以为此我要做一个单独的方法,它将获取要压缩的位置保留文件并将文件名作为参数请告知如何制作此方法并具有压缩逻辑,我已经尝试过这个..
File file = new File(Path + s) //path contain the location of file and s contain the filename
for (File f : new File(mcrpFilePath).listFiles()) {
if (f.getName().endsWith(".csv")) {
if (f.isFile() && file.getName().toLowerCase().endsWith(".csv")) {
f.delete();
}
}
file.createNewFile();
FileOutputStream fileOutput = new FileOutputStream(file);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
fileOutput));
addContent(aalist, bblist, bw);// seprate method that is writing in csv file
bw.close();
fileOutput.close();
// ???? Now here i want to call my zipp method seprately
zipafile(Path + s) //?? what will be logic inside this method to zip the file