I am working on a login for my USB. I know there are other languages that do that better but I am learning Java. I get an error using the IO Console
package access;
import java.awt.Desktop;
import java.io.*;
public class access {
public static void main(String[] args)throws IOException {
BufferedReader reader = new BufferedReader (new InputStreamReader (System.in));
Console c = System.console();
Desktop desktop = Desktop.getDesktop();
File dirToOpen = null;
String user = c.readLine("Username: ");
char pass[] = c.readPassword("Enter password: ");
String uPass = new String(pass);
if(user.equals("yuto") && uPass.equals("abascalesgay")) {
try {
dirToOpen = new File("E:\\encrypted");
desktop.open(dirToOpen);
}
catch (IllegalArgumentException iae) {
System.out.println("File Not Found");
}
}
else {
System.out.println("Credenciales no válidas we, vuelve a intentarlo.");
}
}
}
Error log
Exception in thread "main" java.lang.NullPointerException at access.access.main(access.java:17)