So I was trying to get to get my String files of names to open, but when I run it nothing happens. No errors just nothing.
package test;
import java.io.File;
import java.util.Scanner;
public class file {
    private Scanner x;
    public void openFile(){
        try{
            x = new Scanner(new File("Names.txt"));
        }
        catch(Exception e){
            System.out.println("No file");
        }
    }
    public void readFile(){
        while(x.hasNext());
        String a = x.next();
        System.out.printf("%s" ,x);
    }
    public void closeFile(){
        x.close();
    }
}
package test;
public class main {
    public static void main(String[] args){
    file file = new file();
    file.openFile();
    file.readFile();
    file.closeFile();
    }
}
These are the two classes I made. one with the methods and the other class calls these methods. I there something I'm doing that causing the files to no open? or does it work when you guys try to run it? thanks.
 
     
     
     
    