Example #1
0
 public static void consumeLines(File file, Charset charset, Consumer<String> consumer) {
   try {
     CharSource charSource = com.google.common.io.Files.asCharSource(file, charset);
     try (BufferedReader bufferedReader = charSource.openBufferedStream()) {
       for (String line; (line = bufferedReader.readLine()) != null; ) {
         try {
           consumer.accept(line);
         } catch (Exception e) {
           throw new IllegalStateException(e);
         }
       }
     }
   } catch (IOException e) {
     throw new IllegalArgumentException(e);
   }
 }
Example #2
0
 public static void append(CharSequence from, File to, Charset charset) throws IOException {
   com.google.common.io.Files.append(from, to, charset);
 }