yangys
2024-03-28 23a939ed820ee32f9a4309f9c81b7bab5a566f30
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
package com.qianwen.smartman.modules.cps.utils;
 
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.springframework.core.io.Resource;
 
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/cps/utils/FileUtil.class */
public final class FileUtil {
    private FileUtil() {
        throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
    }
 
    public static String getFileString(Resource classPathResource) throws IOException {
        File file = new File(System.getProperty("java.io.tmpdir") + File.separator + "temp.txt");
        FileUtils.copyToFile(classPathResource.getInputStream(), file);
        Long fileLength = Long.valueOf(file.length());
        byte[] fileContent = new byte[fileLength.intValue()];
        FileInputStream in = new FileInputStream(file);
        in.read(fileContent);
        String fileStr = new String(fileContent);
        in.close();
        return fileStr;
    }
}