Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Vdragon/6f7d215857ebb94fc59d to your computer and use it in GitHub Desktop.
Save Vdragon/6f7d215857ebb94fc59d to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class DetectEmptyLine_Problematic_Demonstration{
public static void main(String args[]){
Scanner standard_input_reader = new Scanner (System.in);
StringBuffer input_line = new StringBuffer();
while(!(input_line.insert(0, standard_input_reader.nextLine()).toString().isEmpty())){
System.out.println(input_line);
input_line.setLength(0);
}
standard_input_reader = null;
input_line = null;
}
}
@legnaleurc
Copy link

public static void main (String args[]) {
    Scanner cin = new Scanner (System.in);
    while (cin.hasNextLine()) {
        String line = cin.nextLine();
        System.out.printf("echo: %s, %d\n", line, line.length());
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment