1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
/**
* Doesn't read lines beginning with # or / and empty lines
*
* @param adress : path to the file
* @return List<String> with one String for each line
* @throws FileNotFoundException if file doesn't exist
* @throws IOException if an error happen while reading
*/
public List<String> read(String adress) throws FileNotFoundException, IOException {
List<String> str = new ArrayList<String>();
InputStream ips = new FileInputStream(adress);
InputStreamReader ipsr = new InputStreamReader(ips);
BufferedReader br = new BufferedReader(ipsr);
String l;
char ch1 = '/';
char ch2 = '#';
while ((l = br.readLine()) != null) {
if (l.length() > 0) {
if (l.charAt(0) != ch1 && l.charAt(0) != ch2) {
str.add(l);
}
}
}
br.close();
ips.close();
return str;
} |