Java, Cannot find text file, with a StkTrc
<p>I get an Error when it tries to create the scanner for the files in the Build functions. After the file is created it has the pathname as the file, but then when the scanner tries to use the file it cannot find the said file. It fails for both scanners.</p>

<p>I just started working on it here a little bit ago, and prior to it this worked fine, I did not alter the build methods or scanning section only to debug, so I know that is still the same. (The first build method has the debug codez removed).</p>

<p>***I will post a picture if people would like of the file, sitting there in "C:\Users\User\Documents\", I know I will get asked if the file is there. </p>

<pre><code>import java.applet.Applet;
import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.StringTokenizer;


public class CLInventorizerMaster extends Applet implements ActionListener
{

/**
 * Version 1.0 
 */
private static final long serialVersionUID = 1L;

Runtime rt = null;

//Data
int m_iNext = 0;
int m_iInventorySize = 2000;
static String m_sInventoryPath = null;
static String m_sMarkedItemsPath = null;
String m_saInventory[] = new String[m_iInventorySize];
String m_saNumber[] = new String[m_iInventorySize];
String m_saDescription[] = new String[m_iInventorySize];
String m_saRetail[] = new String[m_iInventorySize];
String m_saDiscount[] = new String[m_iInventorySize];
String m_saPrice[] = new String[m_iInventorySize];

String m_saMarkedItems[] = new String[m_iInventorySize];
String m_saActive[] = new String[m_iInventorySize];


// Visual
Button m_BtnLoadInventory = null;
Button m_BtnLoadItems = null;
TextField m_TxtLoadInventory = null;
TextField m_TxtLoadItems = null;
TextField m_TxtDescription = null;
TextField m_TxtItemNumber = null;
TextField m_TxtRetail = null;
TextField m_TxtDiscount = null;
TextField m_TxtPrice = null;
TextArea m_TxtaOut = null;
Button m_BtnNext = null;

public void init()
{
    //****Set the layout
    setLayout(new FlowLayout());

    //****Initilize components 
    //Loading
    m_BtnLoadInventory = new Button("    Load Inventory   ");
    m_TxtLoadInventory = new TextField("C:\\Users\\User\\Documents\\InputInventory.txt", 90);
    m_BtnLoadItems = new Button("Load MarkedItems");
    m_TxtLoadItems = new TextField("C:\\Users\\User\\Documents\\ItemsMarked.txt", 90);
    // Info 
    m_TxtDescription = new TextField("Description", 110);
    m_TxtItemNumber = new TextField("0.0000", 20);
    m_TxtRetail = new TextField("$0.00", 20);
    m_TxtDiscount = new TextField("00%", 20);
    m_TxtPrice = new TextField("$0.00", 20);
    m_TxtaOut = new TextArea("&lt;HTML&gt;", 15, 100);
    //Next
    m_BtnNext = new Button("Next");


    //****Add components
    //Loading
    add(m_BtnLoadInventory);
    add(m_TxtLoadInventory);
    add(m_BtnLoadItems);
    add(m_TxtLoadItems);
    //Info
    add(m_TxtDescription);
    add(m_TxtItemNumber);
    add(m_TxtRetail);
    add(m_TxtDiscount);
    add(m_TxtPrice);
    add(m_TxtaOut);
    //Next
    add(m_BtnNext);

    //Start Action listener
    m_BtnLoadInventory.addActionListener(this);
    m_BtnLoadItems.addActionListener(this);
    m_BtnNext.addActionListener(this);

    //Set Size
    this.setSize(800, 600);

    // Other
    rt = Runtime.getRuntime();
}

@Override
public void actionPerformed(ActionEvent evt)
{
    // Load Button, try to load the inventory
    if (evt.getSource() == m_BtnLoadInventory)
    {
        if(m_TxtLoadInventory.getText().length() != 0)
        {
            m_sInventoryPath = m_TxtLoadInventory.getText();
            m_sMarkedItemsPath = m_TxtLoadItems.getText();
            System.out.println(m_sInventoryPath);
            System.out.println(m_sMarkedItemsPath);

            if( this.BuildInventory() )
                m_TxtLoadInventory.setText(" Loaded Succesfully ");
            else
            {
                m_TxtLoadInventory.setText(" FAILED ");
                //System.exit(1);
            }
            if( this.BuildMarkedItems() )
            {
                m_TxtLoadItems.setText(" Loaded Succesfully ");

            }
            else
            {
                m_TxtLoadItems.setText(" FAILED ");
                //System.exit(1);
            }
        } 
     }
     else 
     // Next
     if(evt.getSource() == m_BtnNext)
     {
        if(true)
        {
            // Find the index of the next item in the marked list
            int index = findTerm(m_saMarkedItems[m_iNext]);
            System.out.println(index);
            // Increase next
            m_iNext = m_iNext + 1;
            // If not in the list
            if (index &lt; 0)
            {
                 m_TxtDescription.setText("NOT FOUND IN INVENTORY");
                 m_TxtItemNumber.setText("!!!!!");
                 m_TxtRetail.setText("!!!!!");
                 m_TxtDiscount.setText("!!!!!");
                 m_TxtPrice.setText("!!!!!");
                 m_TxtaOut.setText("!!!!!");
            }
            else
            {
                  if(m_saNumber[index].equals(""))
                  {
                     m_TxtaOut.setText("------- No Number --------");
                     m_TxtRetail.setText(m_saRetail[index]);
                     m_TxtPrice.setText(m_saPrice[index]);
                     m_TxtDescription.setText(m_saDescription[index]);
                  }
                  else
                  {

                    //Update txtOut
                     m_TxtItemNumber.setText(m_saInventory[index]);
                     m_TxtDiscount.setText(m_saDiscount[index]);
                     m_TxtRetail.setText(m_saRetail[index]);
                     m_TxtPrice.setText(m_saPrice[index]);
                     m_TxtDescription.setText(m_saDescription[index]);



                  }
              }
         }
     }
 }

boolean BuildInventory()
{
    Scanner in = null;
    try
    {
        in = new Scanner(new File(m_sInventoryPath));
    }
    catch (FileNotFoundException e)
    {
        System.out.println("Cannot open inventory");
        return false;
    }
    int i = 0;
    while (in.hasNextLine())
    {
        int j = 0;
        StringTokenizer tkner = new StringTokenizer(in.nextLine());
        while (tkner.hasMoreTokens())
        {
            if(j == 0)
                m_saInventory[i] = tkner.nextToken("|");
            else if(j == 1)
                m_saNumber[i] = tkner.nextToken("|");
            else if(j == 2)
                m_saDescription[i] = tkner.nextToken("|");
            else if(j == 3)
                m_saRetail[i] = tkner.nextToken("|");
            else if(j == 4)
                m_saDiscount[i] = tkner.nextToken("|");
            else if(j == 5)
                m_saPrice[i] = tkner.nextToken("|");
            else
                tkner.nextToken("|");
             j++;
        }
        i++;
    }
    in.close();
    return true;
}

boolean BuildMarkedItems()
{
    Scanner in = null;
    try
    {
        File f = new File(m_sMarkedItemsPath);
        System.out.println(f.getPath());
        in = new Scanner(f);
    }
    catch (FileNotFoundException e)
    {
        e.printStackTrace(System.out);
        System.out.println("Cannot open Marked Items");
        return false;
    }
    int i = 0;
    while (in.hasNextLine())
    {
        int j = 0;
        StringTokenizer tkner = new StringTokenizer(in.nextLine());
        while (tkner.hasMoreTokens())
        {
            if(j == 0)
                m_saMarkedItems[i] = tkner.nextToken("|");
            if(j == 1)
                m_saActive[i] = tkner.nextToken("|");
            else
               tkner.nextToken("|");
             j++;
        }
        i++;
    }
    in.close();
    return true;
}

int findTerm(String key)
{
    int lo = 0; int hi = m_iInventorySize - 1;
    while (lo &lt;= hi)
    {
        int mid = (lo + hi) / 2;
        int diff = key.compareTo(m_saInventory[mid]);
        if (diff == 0) return mid;
        if (diff &lt; 0) hi = mid - 1; else lo = mid + 1;
    }
    return -1;
}

}
</code></pre>

<p>STACK TRACE:::::</p>

<pre><code>C:\Users\User\Documents\InputInventory.txt
C:\Users\User\Documents\ItemsMarked.txt
Cannot open inventory
C:\Users\User\Documents\ItemsMarked.txt
java.io.FileNotFoundException: C:\Users\User\Documents\ItemsMarked.txt (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.&lt;init&gt;(Unknown Source)
at java.util.Scanner.&lt;init&gt;(Unknown Source)
at CLInventorizerMaster.BuildMarkedItems(CLInventorizerMaster.java:253)
at CLInventorizerMaster.actionPerformed(CLInventorizerMaster.java:131)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Cannot open Marked Items
</code></pre>
