How to read in a txt file
<p>I'm trying to read in from whats on the first two lines of a txt file, put it on a string and pass that string onto my methods. I'm confused on what I need to do in the main method. </p>

<p>Heres what I have:</p>

<pre><code>    public class TestingClass  {
Stacked s;// = new Stacked(100);
 String Finame;

public TestingClass(Stacked stack) {
    //Stacked s = new Stacked(100);
    s = stack;
    getFileName();
    readFileContents(); 
}

public void readFileContents() {
    boolean looping;
    DataInputStream in;
    String line = "" ;
    int j, len;
    char ch;

    try {
        in = new DataInputStream(new FileInputStream(Finame));
        len = line.length();
        for(j = 0; j&lt;len; j++) {
                System.out.println("line["+j+"] = "+line.charAt(j));
        }
    } 

    catch(IOException e) {
            System.out.println("error " + e);
    }
}   

public void getFileName() {
    Scanner in = new Scanner(System.in);
    System.out.println("Enter File Name");
    Finame = in.nextLine();
    System.out.println("You Entered " + Finame);
}

       public static void main(String[] args) {
         Stacked st = new Stacked(100);
         TestingClass clas = new TestingClass(st);
         //String y = new String("(z * j)/(b * 8) ^2");
         // clas.test(y);

       }
</code></pre>

<p>I tried String x = new String(x.getNewFile()) I'm not sure if thats the right way to go with that or not.     </p>
