I have been trying to get the output of this code to be printed on a .txt file, however I getting an empty file as an output, but I see the correct results in the console, so the problem is with the StreamWriter I think.
So what am I doing wrong?
package Hierarchies;
public static void generateHierarchy() {
Set<Entry<Long, Node>> iterator = graph.entrySet();
int i =0;
for(Entry<Long,Node> e : iterator) {
System.out.println(i++ +" - " +e.getValue().firstParents());
}
}
@SuppressWarnings({ "resource" })
public static void main(String[] args) throws JWNLException {
// TODO Auto-generated method stub
dictionary = Dictionary.getDefaultResourceInstance();
File dir = new File("C:/Users/D060891/Desktop/Thesis/sentencesNYT");
for (File file : dir.listFiles()) {
try {
BufferedReader input = new BufferedReader(new FileReader(file));
String line;
while ((line = input.readLine()) != null) {
demonstrateListHelper(line);
}
}
catch (IOException e) {
e.printStackTrace();
}
}
generateHierarchy();
PrintStream out;
try {
out = new PrintStream(new FileOutputStream("output.txt"));
System.setOut(out);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}