wood burning stoves
The moose likes I/O and Streams and the fly likes why can't see the output in dos window after using buffered reader..?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "why can Watch "why can New topic

why can't see the output in dos window after using buffered reader..??

saurabh panwar

Joined: Feb 19, 2001
Posts: 5
I've a simple program which runs the Dos "dir" command through java. I can See the output in my java text area but when i run this program on the dos prompt it doesn't show anythin and i have to Cntrl-Alt-Del the programe.
My code isimport java.io.*;

public class toyshell2{
public static void main(String args[])
toyshell2 toy = new toyshell2();
}catch(Exception e){
public void init() throws Exception{
String commands[]= new String[3];
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(commands);
CheckStream csin = new CheckStream(process.getInputStream());
String line;
int done = process.waitFor();

class CheckStream{
BufferedReader br;
String lineread = "";
String lines = "";
String str="";
boolean erroroccured;
CheckStream(InputStream is){
this.br = new BufferedReader(new InputStreamReader(is));
catch(Exception e){

/** Reads the input stream and displays anything returned.
public void run(){
while ((lineread = br.readLine()) != null){
catch(Exception e){

Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
I sucessfully compiled and ran your code from the DOS prompt. Could you be more specific about the way you're compiling and running? What "java text area" are you using?
This was the output I got in the DOS window:
C:\Files\Matt\Help>java toyshell2
Volume in drive C is Main Gun
Volume Serial Number is FCB4-E423
Directory of C:\FILES\MATT\HELP
. <DIR> 02/20/01 11:25a
.. <DIR> 02/20/01 11:25a
TOYSHE~1 CLA 1202 02/20/01 11:25a
TOYSHE~1 JAV 1162 02/20/01 11:25a
TOYSHE~2 CLA 1191 02/20/01 11:25a
5 file(s) 3555 bytes
1023932928 bytes free

There's nothing more dangerous than a resourceful idiot. ---Dilbert
saurabh panwar

Joined: Feb 19, 2001
Posts: 5
thanks matt...for carin' to reply...but the prob still persists!!..well i tried something like this.
the output of my dir command is too large and ,may be that's why i 'm not gettin' the output....so i tried to print a large output stored in a text file by my java program(dos command "TYPE") AND TO MU surprise i could only type the file on the dos console when the size of the file was small. I could not type a large file!!!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: why can't see the output in dos window after using buffered reader..??
It's not a secret anymore!