It's not weird at all. readUTF
expects a very specific length-prefixed format as written by DataOutputStream
. That's not what your terminal will be providing. See the documentation in DataInput.readUTF
for more details.
You should generally just use a Scanner
or create an InputStreamReader
around System.in
, and a BufferedReader
around that, and use BufferedReader.readLine()
.