I want to use stream based IPC in Java. To test this I am trying to exec unix more filename command from my java code. Interesting thing is commands like ps, man, ls -l execute fine using the code below. But executing more on a big file , which requires enter input from keyboard occasionally fails. I would like to give input to this unix process from my java code..but I am not sure how to do that. The code I have so far is as follows:
Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.
Your process is likely exceeding the size of the output stream buffer with larger files.
1) Keep polling on input and error streams continuously, you will have to create separate threads which will do that.
2) get the output stream of process and pass the strings to it by taking them from standard input stream of the application. Use system.in for that.