Method getting non blank input

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

Method getting non blank input



I've made method taking non blank input so I can validate input to my list.


public String getNonBlankInput(String text)

Scanner scan = new Scanner(System.in);

System.out.println(text);
String input = scan.nextLine();
while (input.isEmpty()



I would like to use this in my method which adds objects to my LinkedList. Here is code of this method:


public void addMenu()
String log = getNonBlankInput("Enter login: ");
String pass = getNonBlankInput("Enter password: ");
String web = getNonBlankInput("Enter website: ");

Entry newEntry = new Entry(web,log,pass);
edao.addEntry(newEntry);



The problem is, whatever I've put as login, password or website I'm getting Exception:


Exception in thread "main" java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Scanner.java:1540)
at com.password.PasswordManager.data.InputValidation.getNonBlankInput(InputValidation.java:12)
at com.password.PasswordManager.input.MenuImplementation.addMenu(MenuImplementation.java:15)



Anyone have a clue what is wrong here? Before I've created method getNonBlankInput everything was ok.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

Trying to Print Gridster Items to PDF without overlapping contents

Mass disable jenkins jobs