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)
| 516 | * @throws IOException if an I/O error occurs |
| 517 | */ |
| 518 | public static List<String> readLines(File file, Charset charset) throws IOException { |
| 519 | // don't use asCharSource(file, charset).readLines() because that returns |
| 520 | // an immutable list, which would change the behavior of this method |
| 521 | return readLines( |
| 522 | file, |
| 523 | charset, |
| 524 | new LineProcessor<List<String>>() { |
| 525 | final List<String> result = Lists.newArrayList(); |
| 526 | |
| 527 | @Override |
| 528 | public boolean processLine(String line) { |
| 529 | result.add(line); |
| 530 | return true; |
| 531 | } |
| 532 | |
| 533 | @Override |
| 534 | public List<String> getResult() { |
| 535 | return result; |
| 536 | } |
| 537 | }); |
| 538 | } |
| 539 | |
| 540 | /** |
| 541 | * Streams lines from a {@link File}, stopping when our callback returns false, or we have read |
nothing calls this directly
no test coverage detected