MCPcopy Create free account
hub / github.com/antlr/codebuff / readLines

Method readLines

corpus/java/training/guava/io/Files.java:518–538  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

newArrayListMethod · 0.95
asCharSourceMethod · 0.95

Tested by

no test coverage detected