View Javadoc
1   package com.atlassian.plugin.spring.scanner.core.vfs;
2   
3   import java.io.BufferedReader;
4   import java.io.BufferedWriter;
5   import java.io.IOException;
6   import java.io.Reader;
7   import java.io.Writer;
8   import java.util.ArrayList;
9   import java.util.Collection;
10  import java.util.List;
11  import java.util.Properties;
12  
13  /**
14   */
15  public class CommonIO {
16      public static void writeLines(Writer writer, Iterable<String> lines) throws IOException {
17          try (BufferedWriter out = new BufferedWriter(writer)) {
18              for (String line : lines) {
19                  out.write(line);
20                  out.write("\n");
21              }
22          }
23      }
24  
25      public static Collection<String> readLines(Reader reader) throws IOException {
26          List<String> lines = new ArrayList<String>();
27          try (BufferedReader in = new BufferedReader(reader)) {
28              String line;
29              while ((line = in.readLine()) != null) {
30                  lines.add(line);
31              }
32          }
33          return lines;
34      }
35  
36      public static void writeProperties(Writer writer, final Properties properties, final String comment)
37              throws IOException {
38          try (Writer w = writer) {
39              properties.store(w, comment);
40          }
41      }
42  }