按照给定的readerHandler读取文件中的数据

@param <T> 集合类型
@param readerHandler Reader处理类
@param path 文件的绝对路径
@return 从文件中load出的数据
@throws IORuntimeException IO异常
@since 3.1.1
508663
public static <T> T loadUtf8(String path, ReaderHandler<T> readerHandler) throws IORuntimeException {
		return load(path, CharsetUtil.CHARSET_UTF_8, readerHandler);
	}
929135
private static void loadFile(String filePath) {
        final Path path = FileSystems.getDefault().getPath(filePath);

        try {
            data.clear();
            data.load(Files.newBufferedReader(path));
        } catch(IOException e) {
            LOG.warn("Exception while loading " + path.toString(), e);
        }
    }
590226
private JsonObject load(Path path) throws IOException {
    try (InputStream stream = Resources.getResource(path.toString()).openStream()) {
      return (JsonObject) JSON_PARSER.parse(new InputStreamReader(stream));
    }
  }
1310665
public static BufferedReader newBufferedReader(Path path, Charset charset) throws IOException {
        return new BufferedReader(new InputStreamReader(newInputStream(path), charset));
    }
1318842
public static List<String> listFileNames(String path) throws IORuntimeException {
		if (path == null) {
			return null;
		}
		List<String> paths = new ArrayList<String>();

		int index = path.lastIndexOf(FileUtil.JAR_PATH_EXT);
		if (index == -1) {
			// 普通目录路径
			File[] files = ls(path);
			for (File file : files) {
				if (file.isFile()) {
					paths.add(file.getName());
				}
			}
		} else {
			// jar文件
			path = getAbsolutePath(path);
			if (false == StrUtil.endWith(path, UNIX_SEPARATOR)) {
				path = path + UNIX_SEPARATOR;
			}
			// jar文件中的路径
			index = index + FileUtil.JAR_FILE_EXT.length();
			JarFile jarFile = null;
			try {
				jarFile = new JarFile(path.substring(0, index));
				final String subPath = path.substring(index + 2);
				for (JarEntry entry : Collections.list(jarFile.entries())) {
					final String name = entry.getName();
					if (name.startsWith(subPath)) {
						final String nameSuffix = StrUtil.removePrefix(name, subPath);
						if (false == StrUtil.contains(nameSuffix, UNIX_SEPARATOR)) {
							paths.add(nameSuffix);
						}
					}
				}
			} catch (IOException e) {
				throw new IORuntimeException(StrUtil.format("Can not read file path of [{}]", path), e);
			} finally {
				IoUtil.close(jarFile);
			}
		}
		return paths;
	}
1336555
public static ClassFileReader newInstance(Path path, JarFile jf) throws IOException {
        return new JarFileReader(path, jf);
    }
184738
public BufferedReader newBufferedReader(Path path, Charset cs)
    {
        try {
            return Files.newBufferedReader(path, cs);
        } catch (IOException e) {
            return null;
        }
    }
1317612
public static BufferedReader newReader(Path self) throws IOException {
        return Files.newBufferedReader(self, Charset.defaultCharset());
    }
470087
public static <T extends Collection<String>> T readUtf8Lines(String path, T collection) throws IORuntimeException {
		return readLines(path, CharsetUtil.CHARSET_UTF_8, collection);
	}
763793
public static String readFirstLine(String path) throws FileNotFoundException, IOException {
        try (FileInputStream fis = new FileInputStream(path)) {
            try (InputStreamReader isr = new InputStreamReader(fis)) {
                try (BufferedReader br = new BufferedReader(isr)) {
                    return br.readLine();
                }
            }
        }
    }
1020864
public static <T extends Collection<String>> T readLines(String path, Charset charset, T collection) throws IORuntimeException {
		return readLines(file(path), charset, collection);
	}
316523
public static Single<String> read(String path) {
        return SingleRxXian.call("cosService", "cosRead", new JSONObject() {{
            put("path", path);
        }}).flatMap(response -> {
            response.throwExceptionIfNotSuccess();
            return Single.just(Objects.requireNonNull(response.dataToStr()));
        });
    }
1089387
public void readResources(String path) throws IOException {
		Enumeration<URL> resources =
				getClass().getClassLoader().getResources(path);

		if (!resources.hasMoreElements()) {
			throw new IllegalArgumentException(String.format("File %s was not found on classpath", path));
		}

		Yaml yaml = new Yaml();
		while (resources.hasMoreElements()) {
			appendData(yaml.loadAs(resources.nextElement().openStream(), Data.class));
		}
	}
368013
public static BufferedWriter asBufferedWriter(Path path) throws IOException {
		Validate.notNull(path, "path is null");
		return Files.newBufferedWriter(path, Charsets.UTF_8);
	}
95563
public static BufferedReader resource(String resourcePath) throws IOException {
        InputStream is = IOUtils.class.getClassLoader().getResourceAsStream(resourcePath);
        if(is != null) {
            return new BufferedReader(new InputStreamReader(is, UTF_8));
        } else {
            File file = new File(resourcePath);
            if(file.exists()) {
                return fileReader(file);
            } else {
                throw new IllegalArgumentException("resource does not exist " + resourcePath);
            }
        }
    }
1069134
public static <T> T readObjectFromFile(String path, Class<T> type, SparkContext sc) throws IOException {
        FileSystem fileSystem = FileSystem.get(sc.hadoopConfiguration());
        try (ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(fileSystem.open(new Path(path))))) {
            Object o;
            try {
                o = ois.readObject();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            }

            return (T) o;
        }
    }
1285163
public static String readTxt(String path)
    {
        if (path == null) return null;
        try
        {
            InputStream in = IOAdapter == null ? new FileInputStream(path) :
                    IOAdapter.open(path);
            byte[] fileContent = new byte[in.available()];
            int read = readBytesFromOtherInputStream(in, fileContent);
            in.close();
            // 处理 UTF-8 BOM
            if (read >= 3 && fileContent[0] == -17 && fileContent[1] == -69 && fileContent[2] == -65)
                return new String(fileContent, 3, fileContent.length - 3, Charset.forName("UTF-8"));
            return new String(fileContent, Charset.forName("UTF-8"));
        }
        catch (FileNotFoundException e)
        {
            logger.warning("找不到" + path + e);
            return null;
        }
        catch (IOException e)
        {
            logger.warning("读取" + path + "发生IO异常" + e);
            return null;
        }
    }