Guest User

read lines

a guest
Nov 25th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.nio.charset.Charset;
  3. import java.nio.file.Files;
  4. import java.nio.file.Path;
  5. import java.nio.file.Paths;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8.  
  9. public class Main {
  10.  
  11.     public static void main(String[] args) {
  12.     Path path = Paths.get("/etc/rc.local");
  13.         Charset charset = Charset.forName("UTF-8");
  14.         List<String> lines = new ArrayList<>();
  15.         try {
  16.              lines = Files.readAllLines(path, charset);
  17.         } catch (IOException e) {
  18.             System.out.println(e.getMessage());
  19.         }
  20.         for(String line : lines){
  21.             System.out.println(line);
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment