远程文件转换为List
public final class RemoteFileUtils {
private RemoteFileUtils() {
}
/**
* 远程文件转换为List
*
* @param filePath 文件路径
* @param className 类名
* @param <T> 泛型
* @return List
* @throws ServiceCutOverException 自定义异常
*/
public static <T> List<T> convertFileToList(String filePath, Class<T> className) throws ServiceCutOverException {
if (!IPFSUtils.remoteFileExist(filePath)) {
throw new ServiceCutOverException(
String.format(Locale.ENGLISH, "remote File does not exist,path %s", filePath));
}
String result = IPFSUtils.loadContent(filePath, "UTF-8");
return JSON.parseArray(result, className);
}
}