Bom estou estudando os comandos em java e tive um erro no seguinte codigo:
package del;
import java.util.Scanner;
import java.io.IOException;
public class Main {
public static void main(String args[])
throws IOException {
Scanner myScanner = new Scanner(System.in);
char reply;
do {
System.out.print("Reply with Y or N...");
System.out.print(" Delete all .keep files? ");
reply = myScanner.findInLine(".").charAt(0);
} while (reply != 'Y' && reply != 'N');
if (reply == 'Y') {
Runtime.getRuntime().exec("cmd /c del *.keep");
}
}
}
Quando quero deletar os arquivos ".keep", o programa conclui sem erros, mas quando a opcao WHILE eh ativada (se eu escrever por exemplo "s" (while (reply != 'Y' && reply != 'N');))
da o seguinte erro:
run:
Reply with Y or N... Delete all .keep files?
s
Exception in thread "main" java.lang.NullPointerException
at del.Main.main(Main.java:21)
Reply with Y or N... Delete all .keep files?
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 4 segundos)
Eu uso o Netbeans, obrigado.