I'm trying to write a file from my Java program, but nothing happens. I'm not getting any exceptions or errors, it's just silently failing.
try {
File outputFile = new File(args[args.length - 1]);
outputFile.delete();
outputFile.createNewFile();
PrintStream output = new PrintStream(new FileOutputStream(outputFile));
TreePrinter.printNewickFormat(tree, output);
} catch (IOException e) {
e.printStackTrace();
return;
}
Here is the TreePrinter
function:
public static void printNewickFormat(PhylogenyTree node, PrintStream stream) {
if (node.getChildren().size() > 0) {
stream.print("(");
int i = 1;
for (PhylogenyTree pt : node.getChildren()) {
printNewickFormat(pt, stream);
if (i != node.getChildren().size()) {
stream.print(",");
}
i++;
}
stream.print(")");
}
stream.format("[%s]%s", node.getAnimal().getLatinName(), node.getAnimal().getName());
}
What am I doing wrong?