• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

controlling Command Prompt window's size?

 
Miguel Antonioli
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My dearest Java guru,

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.

Regards,
Miguel
 
Campbell Ritchie
Sheriff
Pie
Posts: 50175
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

CR
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Miguel Antonioli:
The question now, is there anyway we can control the buffer size of the
command prompt from Java?

No. Java cannot control the command prompt window. That is a Windows OS specific thing that Java knows nothing about.
 
Bill Johnston
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know if this will help you but you can do:

/cmd /C start /min
-or-
/cmd /C start /max

... 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(

~Bill
 
Miguel Antonioli
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Cheers,
 
Miguel Antonioli
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

CR


It's an XP command prompt.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic