Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dot工具二进制搜索树Java_Java - Fatal编程技术网

Dot工具二进制搜索树Java

Dot工具二进制搜索树Java,java,Java,我只是尝试在向BinarySearchTree添加整数后写入点文件,但在执行时不会向项目文件生成任何文件 public void testadd() { BinarySearchTree<Integer> bst = new BinarySearchTree<Integer>(); bst.add(1); bst.add(2); bst.add(3); bst.add(4); bst.add(5); bst.w

我只是尝试在向BinarySearchTree添加整数后写入点文件,但在执行时不会向项目文件生成任何文件

 public void testadd()
{
    BinarySearchTree<Integer> bst = new BinarySearchTree<Integer>();

    bst.add(1);
    bst.add(2);
    bst.add(3);
    bst.add(4);
    bst.add(5);

    bst.writeDot("BST.dot");
}
public void testadd()
{
BinarySearchTree bst=新的BinarySearchTree();
bst.add(1);
bst.add(2);
bst.add(3);
bst.add(4);
bst.add(5);
bst.writeDot(“bst.dot”);
}

BinarySearchTree是哪个库(包)的一部分?
writeDot()
方法的实现将决定它的输出应该是什么,以及是否可以创建文件。您提供的任何代码都不应该写入文件。我们需要看到应该写入文件的部分。
public static PrintStream out;

public void writeToFile( ) throws IOException{
         out = new PrintStream(new FileOutputStream("BST.dot")); 
         writeToFile(root);
         out.close();
}

public void writeToFile(BinaryTreeNode  t) throws IOException
{


            if (t != null)
            {
                System.setOut(out);   
                System.out.println(t.info);
                writeToFile(t.left); 
                writeToFile(t.right);

            }
}