使用InputStream读取文件
try {
File file = new File(filePath);
FileInputStream inputStream = new FileInputStream(file);
int size = inputStream.available();
byte[] buffer = new byte[size];
inputStream.read(buffer);
inputStream.close();
String jsonString = new String(buffer, StandardCharsets.UTF_8);
return JSON.parseObject(jsonString, targetClass);
} catch (IOException e) {
throw new RuntimeException("dsd", e);
}
}