mirror of
https://gitee.com/anji-plus/report.git
synced 2026-03-24 09:48:34 +08:00
hotfix-----windows导入大屏乱码问题
This commit is contained in:
@@ -8,6 +8,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Enumeration;
|
||||
@@ -116,9 +117,11 @@ public class FileUtil {
|
||||
*/
|
||||
public static String readFile(File file) {
|
||||
BufferedReader reader = null;
|
||||
InputStreamReader isr = null;
|
||||
StringBuilder sbf = new StringBuilder();
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
isr = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
||||
reader = new BufferedReader(isr);
|
||||
String tempStr;
|
||||
while ((tempStr = reader.readLine()) != null) {
|
||||
sbf.append(tempStr);
|
||||
@@ -129,6 +132,13 @@ public class FileUtil {
|
||||
log.error("读文件失败", e);
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage());
|
||||
} finally {
|
||||
if (null != isr) {
|
||||
try {
|
||||
isr.close();
|
||||
} catch (IOException e) {
|
||||
throw BusinessExceptionBuilder.build(ResponseCode.FAIL_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
|
||||
Reference in New Issue
Block a user