I have problem with my program. I would like to have access to keystore, user give a pass and path. my code:
public class cipher_player {
public static void main(String[] args) throws Exception{
KeyStore klucz = KeyStore.getInstance("JCEKS");
Console konsola = System.console();
char passwordArray[] = konsola.readPassword("Password: ");
java.io.FileInputStream plik_keystore = null;
try{
Scanner scanner = new Scanner(System.in);
System.out.print("Path to keystore: ");
String pathArray = konsola.readLine();
System.out.print(pathArray);
plik_keystore = new java.io.FileInputStream(pathArray);
klucz.load(plik_keystore, passwordArray);
if(plik_keystore != null){
plik_keystore.close();
}
scanner.close();
}
catch(FileNotFoundException e)
{
System.out.println("Keystore not found");
System.exit(0);
}
}
}
and when I run it display this error
Exception in thread "main" java.lang.NullPointerException
at crypto3.cipher_player.main(cipher_player.java:47)
its line with char passwordArray[] = konsola.readPassword("Password: ");
I don't have idea how solve this problem.