Ejemplo n.º 1
0
 @NotNull
 public static List<String> loadLines(@NotNull Reader reader) throws IOException {
   List<String> lines = new ArrayList<String>();
   BufferedReader bufferedReader = new BufferedReader(reader);
   try {
     String line;
     while ((line = bufferedReader.readLine()) != null) {
       lines.add(line);
     }
   } finally {
     bufferedReader.close();
   }
   return lines;
 }
  @Nullable
  private static String getContent(File file) {
    try {
      StringBuilder content = new StringBuilder();
      BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
      try {
        do {
          String line = reader.readLine();
          if (line == null) break;
          content.append(line);
          content.append('\n');
        } while (true);
      } finally {
        reader.close();
      }

      return content.toString();
    } catch (Exception e) {
      return null;
    }
  }