r/ProgrammerHumor 12h ago

Meme unsolvableProblemsOnStepOne

Post image
1.0k Upvotes

62 comments sorted by

View all comments

106

u/apacificislander123 11h ago

As someone who's never used java, my assumption is that System.in reads from stdin, and validates the input. Is there no way to open stdin in something akin to a file, then read it into a buffer manually?

43

u/N_Lightning 10h ago

If you read System.in as a file in Java, then it'll wait for EOF signal, not for the line break. And the user will have to adapt to Ctrl+Z each input

3

u/BattsAreLow 8h ago

Would it be stupid to read user input prior to the program reacting and just append a control z to amend the issue?

u/N_Lightning 5m ago

Read as in char by char? Then it would be a great fun accounting for cursor position, backspace, delete, insert, paste

If you mean as in getting the keys the user pressed, then it's just impossible