65 lines
1.5 KiB
Java
65 lines
1.5 KiB
Java
package aiyh.utils.entity;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
import weaver.file.FileUpload;
|
|
import weaver.system.SystemComInfo;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.nio.charset.Charset;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Paths;
|
|
import java.util.UUID;
|
|
import java.util.zip.ZipOutputStream;
|
|
|
|
/**
|
|
* @author EBU7-dev1-ayh
|
|
* @create 2021/10/25 0025 17:38
|
|
* zipoutputstaream
|
|
*/
|
|
|
|
|
|
public class AZipOutputStream extends ZipOutputStream {
|
|
|
|
private ZipOutputStream zipOutputStream;
|
|
public static String filePath;
|
|
private OutputStream out;
|
|
static {
|
|
filePath = FileUpload.getCreateDir(new SystemComInfo().getFilesystem()) + "tempfile" + File.separator;
|
|
filePath += "zip" + File.separator + System.currentTimeMillis() + UUID.randomUUID() + ".zip";
|
|
}
|
|
|
|
public AZipOutputStream(@NotNull OutputStream out) {
|
|
super(out);
|
|
this.out = out;
|
|
}
|
|
|
|
public AZipOutputStream(@NotNull OutputStream out, @NotNull Charset charset) {
|
|
super(out, charset);
|
|
this.out = out;
|
|
}
|
|
|
|
@Override
|
|
public void close() throws IOException {
|
|
try {
|
|
Files.deleteIfExists(Paths.get(AZipOutputStream.filePath));
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}finally {
|
|
out.flush();
|
|
super.flush();
|
|
super.close();
|
|
out.close();
|
|
}
|
|
}
|
|
|
|
public ZipOutputStream getZipOutputStream() {
|
|
return zipOutputStream;
|
|
}
|
|
|
|
public void setZipOutputStream(ZipOutputStream zipOutputStream) {
|
|
this.zipOutputStream = zipOutputStream;
|
|
}
|
|
}
|