Reads all of the lines from a file. The lines do not include line-termination characters, but do include other leading and trailing whitespace. This method returns a mutable List. For an ImmutableList, use Files.asCharSource(file, charset).readLines(). @param file the fi
(File file, Charset charset)
| 548 | |
| 549 | |
| 550 | public static List<String> readLines(File file, Charset charset) throws IOException { |
| 551 | // don't use asCharSource(file, charset).readLines() because that returns |
| 552 | // an immutable list, which would change the behavior of this method |
| 553 | return readLines(file, charset, new LineProcessor<List<String>>() { |
| 554 | final List<String> result = Lists.newArrayList(); |
| 555 | |
| 556 | @Override |
| 557 | public boolean processLine(String line) { |
| 558 | result.add(line); |
| 559 | return true; |
| 560 | } |
| 561 | |
| 562 | @Override |
| 563 | public List<String> getResult() { |
| 564 | return result; |
| 565 | } |
| 566 | }); |
| 567 | } |
| 568 | |
| 569 | /** |
| 570 | * Streams lines from a {@link File}, stopping when our callback returns false, or we have read |
nothing calls this directly
no test coverage detected