I have the program I want to test:
while(true) {
//useful code
try {
id = inputValue();
} catch (InputMatchException e) {
System.out.println("blahblah");
}
}
public int inputValue() throws IOException {
InputStream inputStream = ???
System.setIn(inputStream);
Scanner scanner = new Scanner(System.in);
return scanner.nextInt();
}
Here I want that inputValue returns string at first iteration and results in catch block and second time returns 0. Is it possible to do? The loop has conditions to exit) No worries about it.
Aucun commentaire:
Enregistrer un commentaire