• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

controlling Command Prompt window's size?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic