wiley_pastebin icon

non-blocking IO

wiley_pastebin | PRO | 03/15/19 03:24:53 PM UTC | 0 ⭐ | 2294 👁️ | Never ⏰ | []
Java |

460 B

|

None

|

0 👍

/

0 👎

public List<String> readFile(String file){ 
 try { 
  Path path = Paths.get(file); 
  return Files.readAllLines(path,                   
           StandardCharsets.UTF_8); 
 } catch (IOException e) { 
 // io exception reading from file...
 }
  return null; 
} 
 
public void writeToFile(String file, List<String> lines){ 
 try { 
  Path path = Paths.get(file); 
  Files.write(path, lines); 
 } catch (IOException e) { 
 // io exception writing to file...
 } 
}

Comments