How to run this Runtime.getRuntime().exec("cat finename grep ,000 wc -l"

Hi,

I dont know how to run this ,

To get number of line in Linux , we put as

Cat file.txt | grep ,000 | wc -l

I have to put in

Runtime.getRuntime().exec(" Cat file.txt | grep ,000 | wc -l ");

but null is returning in

how to give this

Thanks,

Kamal.

[313 byte] By [kamalhasanka] at [2007-11-27 1:24:59]
# 1

I think you're using it wrong, try this...

try {

Process process = Runtime.getRuntime().exec(" Cat file.txt | grep ,000 | wc -l");

/*

*OR process = Runtime.getRuntime().exec(new String[]{"Cat","file.txt","|","grep",",000","|","wc","-1"});

*/

BufferedReader inputReader = new BufferedReader(new InputStreamReader(process.getInputStream()));

String line;

/*

* The following block should be in its own thread.. because readLine() blocks.

*/

while (((line = inputReader.readLine()) != null)) {

System.out.println(line);

}

} catch (IOException e) {

e.printStackTrace();

}

The_Merovingiana at 2007-7-12 0:17:02 > top of Java-index,Desktop,Runtime Environment...