I am expecting input with the scanner until there is nothing (i.e. when user enters a blank line). How do I achieve this?
I tried:
while (scanner.ha
Scanner key = new Scanner(new File("data.txt")); String data = ""; while(key.hasNextLine()){ String nextLine = key.nextLine(); data += nextLine.equals("") ? "\n" :nextLine; } System.out.println(data);