远程文件转换为List

  1. public final class RemoteFileUtils {
  2. private RemoteFileUtils() {
  3. }
  4. /**
  5. * 远程文件转换为List
  6. *
  7. * @param filePath 文件路径
  8. * @param className 类名
  9. * @param <T> 泛型
  10. * @return List
  11. * @throws ServiceCutOverException 自定义异常
  12. */
  13. public static <T> List<T> convertFileToList(String filePath, Class<T> className) throws ServiceCutOverException {
  14. if (!IPFSUtils.remoteFileExist(filePath)) {
  15. throw new ServiceCutOverException(
  16. String.format(Locale.ENGLISH, "remote File does not exist,path %s", filePath));
  17. }
  18. String result = IPFSUtils.loadContent(filePath, "UTF-8");
  19. return JSON.parseArray(result, className);
  20. }
  21. }