I'm writing a Java program that suppose to read some (possibly huge) lines of input from the Window's command prompt using InputStreamReader.
The problem comes if there was a long line of input being read. Suppose the line consists of 200 characters (including white spaces), but the command prompt's screen only fits 80 characters per line. My program will then receive such input in two lines. The first line consists of the most amount of words possible, while the second line consists of the rest of the words. If I increase the size of the command prompt window so that it can holds 200 character, the problem went away.
The question now, is there anyway we can control the buffer size of the command prompt from Java? I read that BufferedReader constructor can receive a second parameter (an int) that represents the size of the buffer. But, I don't think this is what I need to do. Any help/suggestions will be greatly appreciated.
Which version of Command Prompt are you using? That on WinXP has properties which appear if you click the icon at its top-left corner, which includes size of buffer, size of screen etc. Is that what you want?
... At any rate c>help cmd at your prompt might offer more info. I suppose you realize you can run these via the: Process myProcess = Runtime.getRuntime().exec(
Joined: Apr 09, 2005
Thank you all for the good inputs. What I really want to do is to execute a command from Java (using Runtime's exec), then reads the input directly from the buffer and store those info in the buffer to a String variable. It turns out that the buffer only limits 78 characters per line. When I execute such command directly from the command prompt, each result line contains at least 100 characters.
I created a JAR file so that the class won't execute from the command prompt. But, it turns out the buffer is the problem (well, at least this is what I thought).
So, now I'm just redirect the result of the command to a temporarily file, and reads the result from the file, then do the analysis from that point. I hope this will solve my problem.
Joined: Apr 09, 2005
Originally posted by Campbell Ritchie: Which version of Command Prompt are you using? That on WinXP has properties which appear if you click the icon at its top-left corner, which includes size of buffer, size of screen etc. Is that what you want?