Skip to content
Advertisement

Can’t get stdin to read into array on linux – Java

So I’m using Java on a Linux machine and I currently am trying to read from stdin so that when I run “java Simulation more ~test/locationOfInput/test” it takes a stream of numbers and calculates values and prints them. However, my code is locking up when trying to read in the values and I have a check for empty files so I know it’s at least receiving the file. I currently have this code to read the stdin into an array

JavaScript

The loop seems to be running infinitely and I’m not sure why. Am I misunderstanding how to read in from STDIN?

Advertisement

Answer

You need to use cat ~test/locationOfInput/test | java Simulation to redirect the output properly.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement