import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
public class test {
public static void main(String[] args) {
Runtime run = Runtime.getRuntime();
try {
Process pp=run.exec("progs"); // for cmd commands use=> run.exec("cmd /c dir"); where dir is a command. another eg=>run.exec("cmd /c javac x.java")
BufferedReader in =new BufferedReader(new InputStreamReader(pp.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
}
//run.exec("cmd /c start"); for opening cmd
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
public class test {
public static void main(String[] args) {
Runtime run = Runtime.getRuntime();
try {
Process pp=run.exec("progs"); // for cmd commands use=> run.exec("cmd /c dir"); where dir is a command. another eg=>run.exec("cmd /c javac x.java")
BufferedReader in =new BufferedReader(new InputStreamReader(pp.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
}
//run.exec("cmd /c start"); for opening cmd
No comments:
Post a Comment