Guest User

Untitled

a guest
Apr 25th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. ```java
  2. // 读取路径
  3. File file = new File(KeyWordExtract.class.getResource("/").getPath() + classpath);
  4. if (file.exists()) {
  5. return Files.readAllLines(file.toPath());
  6. }
  7. // 高效的类加载器方式获取文件
  8. InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(classpath);
  9. BufferedReader buffer = new BufferedReader(new InputStreamReader(in));
  10. return buffer.lines().collect(Collectors.toList());
  11. ```
Add Comment
Please, Sign In to add comment