I’ve never used java from the terminal before, and I certainly have never coded for it. My question is simple: How do I intake a file when the calling format is
cat file.txt | java YourMainClass
I have the rest of the code up and running swimmingly, I just need to take the given file name into my main method.
Since the cat command displays the contents of the file, you need to use the System.in buffer to capture the data coming in from that command. You can use a BufferedReader pointing to System.in to loop through the data and process it.
Look at this Example