wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes controlling Command Prompt window's size? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "controlling Command Prompt window Watch "controlling Command Prompt window New topic
Author

controlling Command Prompt window's size?

Miguel Antonioli
Greenhorn

Joined: Apr 09, 2005
Posts: 12
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

Joined: Oct 13, 2005
Posts: 38016
    
  22
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

Joined: Jul 22, 2000
Posts: 9044
    
  10
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.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Bill Johnston
Ranch Hand

Joined: Nov 17, 2005
Posts: 201
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


~Bill
Miguel Antonioli
Greenhorn

Joined: Apr 09, 2005
Posts: 12
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

Joined: Apr 09, 2005
Posts: 12
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.
 
 
subject: controlling Command Prompt window's size?
 
Similar Threads
to read intgers into program
problem with DataInputStream.readInt() method
write reversed lines to a file
What is command line interpreter?
JAR with no Command Prompt involved