コード例 #1
0
 @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);
   }
 }
コード例 #2
0
ファイル: Files.java プロジェクト: pawelprazak/java-extended
 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);
   }
 }