- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnixCommand.java
More file actions
Latest commit
18 lines (17 loc) · 522 Bytes
/
Copy pathUnixCommand.java
File metadata and controls
18 lines (17 loc) · 522 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
importjava.io.BufferedReader;
importjava.io.IOException;
importjava.io.InputStreamReader;
publicclassUnixCommand {
publicstaticvoidmain(String[] args) throwsIOException, InterruptedException {
//String cmd = "ls -l";
Stringcmd2 = "pwd";
Runtimerun = Runtime.getRuntime();
Processpr = run.exec(cmd2);
pr.waitFor();
BufferedReaderbuf = newBufferedReader(newInputStreamReader(pr.getInputStream()));
Stringline = "";
while ((line=buf.readLine())!=null) {
System.out.println(line);
}
}
}