now it reads a file, to have a List<String> from a file.

This commit is contained in:
Vincent Batts 2012-10-04 15:43:26 -04:00
parent 02eb42c4aa
commit 68ade68d4e

View file

@ -1,14 +1,25 @@
package com.hashbangbash.trie; package com.hashbangbash.trie;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException;
public class App { public class App {
public static void main(String[] args) { public static void main(String[] args) {
FileInputStream fis; FileInputStream fis;
DataInputStream in; DataInputStream in;
BufferedReader br;
String content;
List<String> contentList;
for (String arg : args) { for (String arg : args) {
try { try {
@ -20,6 +31,21 @@ public class App {
System.out.printf("ERROR: [%s] %s\n", arg, t); System.out.printf("ERROR: [%s] %s\n", arg, t);
continue; continue;
} }
in = new DataInputStream(fis);
br = new BufferedReader(new InputStreamReader(in));
contentList = new ArrayList<String>();
try {
while ((content = br.readLine()) != null) {
contentList.add(content);
}
} catch (IOException ex) {
System.out.printf("ERROR: [%s] - %s\n", arg, ex);
continue;
}
System.out.println(contentList.toString());
} }
} }
} }