How to read data using Runtime

I wrote the following program to read data from the required file during the runtime. But I'm unable to get any data.

import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.io.IOException;

import java.io.File;

publicclass RunTime1

{

publicstaticvoid main(String args[])

{

Process p=null;

File filename=new File("RunTime1.java");

BufferedReader reader=null;

String[] cmdarray={"notepad",filename.getAbsolutePath()};

String line=null;

try{

p=Runtime.getRuntime().exec(cmdarray);

reader=new BufferedReader(new InputStreamReader(p.getInputStream()));

p.waitFor();

while((line=reader.readLine())!=null)

System.out.println(line+"-->");

}catch(IOException e){}

catch(InterruptedException ie){}

}

}

What's wrong with this program? Please answer me.

[1974 byte] By [Praneeth528a] at [2007-11-26 15:14:14]
# 1

Invoke notepad <filename> from a command prompt. What is the output to the prompt? Nothing!

The same is said for the output to Runtime which is exactly the same as the output the command prompt: nothing. If you want to open a file using Java, use a FileReader object, not the Runtime.

gimbal2a at 2007-7-8 9:05:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks a lot
Praneeth528a at 2007-7-8 9:05:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...