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;
|
}
|
}
|