yangys
2025-07-04 fc588c6e5ccac038cab378931d9bac3033e28f98
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package org.springblade.mdm.utils;
 
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
 
public class FileExchangeUtil {
 
    public static InputStream convertFileToZip(InputStream inputStream) throws IOException {
 
        File tempFile = createTempFile();
        FileOutputStream fos = new FileOutputStream(tempFile);
        CustomBinaryReader.read(inputStream,fos);
 
 
        FileInputStream dInstream = new FileInputStream(tempFile);
 
        return dInstream;
    }
 
    public static File createTempFile() throws IOException {
        Path tempDir = Paths.get(System.getProperty("java.io.tmpdir"));
        // 在临时目录中创建文件
        String tfilename = "t"+System.currentTimeMillis();
        Path tempFile = Files.createTempFile(tempDir, tfilename, ".tmp");
        System.out.println("创建的临时文件: " + tempFile);
        return tempFile.toFile();
    }
}