@SuppressWarnings({"rawtypes", "unchecked"})
 public static Props fromProperties(final CharSource source) throws IOException {
   try (BufferedReader reader = source.openBufferedStream()) {
     final Properties properties = new Properties();
     properties.load(reader);
     return new ImmutableSortedMapProps((Map) properties);
   }
 }
Exemple #2
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);
   }
 }