I'm trying to create a save file but I get a NullPointerException when I try to call the method "fileUserName". can somebody please exsplain why I get this error and how to fix it?
public class Register {
GridPane grid;
. . . .
public Pane getPane() {
    TextField text_name = new TextField();
    TextField text_password = new TextField();
    TextField text_reenterpassword = new TextField();
    Button button_ok = new Button("OK");
    button_ok.setOnAction(e -> {
        String userName=text_name.getText();
        String password=text_password.getText();
        String rePassword=text_reenterpassword.getText();
        DataSaving dataSave=new DataSaving(userName,password);
            if (! (new File("src/data/user/ "+userName).exists()))  {
                FileHandle fileUser= dataSave.fileUserName("src/data/user/"+userName);
                dataSave.saveUser(fileUser);
            }
            new LevelEstimation();
            stage.close();
    });     
    return grid;
  }}   
public class DataSaving {
String userName,password;
int userId;
public static String userPath;
public DataSaving(String username,String pass)
{
    this.userName=username;
    this.password=pass;
}
public static FileHandle fileUserName(String userName)
{
     return Gdx.files.local(userName+"/"+"loginData.json");
}
public void saveUser(FileHandle loginFile)  // saving the user name and password in a file
{
    User user=new User(userName,password);
    Json json=new Json();
    json.setOutputType(OutputType.json);    //to set quotation in json file to each string
    loginFile.writeString(json.prettyPrint(user), false);
}
}
so, I get the error when the method "fileUserName" in the class "DataSaving" is called bei clicking the Butto "button_ok" inside the class "Register"
Any help would be appreciated, thanks.
 
    