problem with print output to a .txt file in java
<p>i write a program in netbeans, but i can not print it in a .txt file. 
indead, my programming codes do note work properly.
i think the problem is in last lines of codes.
here is my codes:</p>

<hr>

<pre><code>import java.io.*;
import java.util.*;

public class converttopathbased_bfs 
{

    static String START;
    static String END;
    static int numberOfNodes;
    static int numberOfArcs;
    static int numberOfCommodities;
    static int OriginDestinationOfCommodities[][] = new int[numberOfCommodities][2];
    static int neighborhoods[][] = new int[numberOfNodes][numberOfNodes];
    static int variableCosts[][] = new int[numberOfNodes][numberOfNodes];
    static int capacities[][] = new int[numberOfNodes][numberOfNodes];
    static int fixedCosts[][] = new int[numberOfNodes][numberOfNodes];
    static int demandOfCommodities[] = new int[numberOfCommodities];
    java.io.File file = new java.io.File("pathBasedTest.txt");
     java.io.PrintWriter output;


    public static void main(String[] args) throws Exception
    {
        java.io.File data = new java.io.File("samples//test.txt");
        Scanner scanner = new Scanner(data);

        numberOfNodes = scanner.nextInt();

        numberOfArcs = scanner.nextInt();

        numberOfCommodities = scanner.nextInt();

        Graph graph = new Graph();

        for (int i = 0; i &lt; numberOfArcs; i++)
        {
            int m = scanner.nextInt() - 1;
            int n = scanner.nextInt() - 1;

            String S = "";
            String E = "";

            S = Integer.toString(m + 1);
            E = Integer.toString(n + 1);

            scanner.nextInt();

            scanner.nextInt();
            scanner.nextInt();

            graph.addEdge(S, E);

                scanner.nextInt();
            scanner.nextInt();
        }


        for (int i = 0; i &lt; numberOfCommodities; i++)
        {            
            converttopathbased_bfs.START = scanner.next();
            converttopathbased_bfs.END = scanner.next();
            scanner.nextInt();

        LinkedList&lt;String&gt; visited = new LinkedList();
        visited.add(START);
        new converttopathbased_bfs().breadthFirst(graph, visited);
        }
    }

    private void breadthFirst(Graph graph, LinkedList&lt;String&gt; visited)  throws Exception
    {
        output = new java.io.PrintWriter (file) ;
        LinkedList&lt;String&gt; nodes = graph.adjacentNodes(visited.getLast());
        // examine adjacent nodes 
        for (String node : nodes)
        {
            if (visited.contains(node))
            {
                continue;
            }
            if (node.equals(END))
            {
                visited.add(node);
                printPath(visited);
                visited.removeLast();
                break;
            }
        }
        // in breadth-first, recursion needs to come after visiting adjacent nodes 
        for (String node : nodes)
        {
            if (visited.contains(node) || node.equals(END))
            {
                continue;
            }
            visited.addLast(node);
            breadthFirst(graph, visited);
            visited.removeLast();
        }
    }

    private void printPath(LinkedList&lt;String&gt; visited) 
    {       
        for (String node : visited)
        {
            output.printf("s", node);
            output.printf(" ");
        }
        output.printf("\n");
    }
} 
</code></pre>

<hr>
