wiley_pastebin

non-blocking IO

Mar 15th, 2019
2,341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. public List<String> readFile(String file){
  2.  try {
  3.   Path path = Paths.get(file);
  4.   return Files.readAllLines(path,                  
  5.            StandardCharsets.UTF_8);
  6.  } catch (IOException e) {
  7.  // io exception reading from file...
  8.  }
  9.   return null;
  10. } 
  11.  
  12. public void writeToFile(String file, List<String> lines){
  13.  try {
  14.   Path path = Paths.get(file);
  15.   Files.write(path, lines);
  16.  } catch (IOException e) {
  17.  // io exception writing to file...
  18.  }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment