I'm working on a code that reads user input, so I've made a procedure that does just that, reads and return the string. when calling it twice from another procedure, returns a NoSuchElementException error which I can't figure out why.
input reader proc:
public static String read() {
72 Scanner leer = new Scanner(System.in);
73 String entry = leer.nextLine();
74 leer.close();
75 return entry;
}
how I'm using it:
...
System.out.println("input value ");
String padre = Entrada.read();
System.out.println("input values ");
27 String reemplazado = Entrada.read();
...
I'm getting
Exception in thread "main" java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Unknown Source)
at modulocarga.Entrada.leerEntradaUsuario(Entrada.java:73)
at modulocarga.TablaSimbolica.addTaxonomica(TablaSimbolica.java:27)
at modulocarga.Principal.main(Principal.java:8)
works fine the first time I call it then it crashes. what could it be?