-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunls.java
More file actions
27 lines (24 loc) · 704 Bytes
/
Copy pathRunls.java
File metadata and controls
27 lines (24 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//import java.io.BufferedReader;
import java.io.InputStream;
import java.io.IOException;
class Runls {
public static void main(String[] args) {
try
{
// Command to create an external process
String command = "ls";
InputStream iStream = null;
// Running the above command
Runtime run = Runtime.getRuntime();
Process proc = run.exec(command);
iStream = proc.getInputStream();
int line;
while ((line = iStream.read()) != -1) {
System.out.println(line);
}
}
catch (IOException e) {
e.printStackTrace();
}
}
}