Я пытаюсь написать файл из своей Java-программы, но ничего не происходит. Я не получаю никаких исключений или ошибок, это просто бесшумно.Java: Почему мой файл не работает?
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;
}
Вот TreePrinter
функция:
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());
}
Что я делаю неправильно?
Этот код, как минимум, может создать (возможно, пустой) файл или вызвать какое-либо исключение. –