Help with execute command
Hi everyone:
i'm new here, and need a help from excellent developers.
two Q please:
1- how i can run a command by java?
i hava oracle, and need to run "tnsping" on the cmd shell.
so how i can execute tnsping?.
2- how i can analyze a line that i read from file?.
i.e: i need to read a file and search on some words in it.
how can i do this by java code.
[409 byte] By [
Marwana] at [2007-11-26 18:37:37]

# 3
Recently, foreign scholar had a thorough research on [url=http://www.viccol.com/]game
[/url] industry and discover : the current overcast appearance of the
[url=http://www.viccol.com/]game[/url] industry is justtemporary phenomenon.in
future several years , the whole [url=http://www.viccol.com/Runescape%20Game.html/]game
[/url] industry will turn into a new stage of high-speed development.
According to one professional 's research to [url=http://www.viccol.com/Runescape%
20Game.html/]game[/url] industry for several years, the sale sum of T.V.
[url=http://www.viccol.com/Runescape%20Game.html/]game[/url] has already exceeded the
income of movie . and will quickly exceed CD in several years in the future. Result in
this is : because of the quick development of Internet . most music can be downloaded
from the net . the CD market status will atrophy gradually.
Moreover research indicate that the average age of
[url=http://www.viccol.com/Runescape%20Game.html/]game[/url] player can attain 33 years
old, but in the whole player community, comparison of female player shared 38% or so.
The research also shows that in all inquisitions, although the NO. 1 Sale quantity is
action game . but actuallymost people think the [url=http://www.viccol.com/]game
[/url] like 乻virtual life 乼issuccessfuland be approved by player for a long
preiod of time . it shows more humanity and pay more attention to express a social
interaction .Because of this kind of [url=http://www.viccol.com/]game[/url] have no
violence composition, so it seems become most popular among players .
There are some weakness of [url=http://www.viccol.com/]game[/url] industry with the
high-speed of development .the expert thinks that development period of
[url=http://www.viccol.com/]game[/url] industry is still short, in the game work lack
of the contents concerning literature, art and scientific knowledge etc., therefore
very difficult to attract age compare bigger consumer .This part of consumers will not
have interest to participate in the [url=http://www.viccol.com/Runescape%20Game.html/]
game[/url] . it becomes the gap between the old and the young. how to work亱out this
problem will be one of an important topics in the [url=http://www.viccol.com/]game[/url]
industry faces in the future
# 4
here is the code you need ;)
static class StreamGobbler extends Thread {
private InputStream is;
private StringBuilder message = new StringBuilder("");
StreamGobbler(InputStream is) {
this.is = is;
start();
}
public String getMessage() {
return message.toString();
}
public void run() {
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line;
try {
while((line = br.readLine())!=null) {
message.append(line+"\n");
}
} catch (IOException e) {
message.append(MessagePacket.toString(e));
}
}
}
public static String executeCommand(boolean wait, String...cmd) throws IOException, InterruptedException {
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec(cmd);
StreamGobbler esg = new StreamGobbler(proc.getErrorStream());
StreamGobbler isg = new StreamGobbler(proc.getInputStream());
if(wait) {
proc.waitFor();
esg.join();
isg.join();
}
return esg.getMessage().trim().length()>0?esg.getMessage():isg.getMessage();
}
}
the wait parameter determines wether to wait till the command finishes. In that case you get the output as return String.