-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoutingTablePrinter.java
More file actions
31 lines (28 loc) · 879 Bytes
/
RoutingTablePrinter.java
File metadata and controls
31 lines (28 loc) · 879 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
28
29
30
31
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class RoutingTablePrinter
{
public void printRoutingTable()
{
try
{
//Executes the "route print" command on Windows
Process process = Runtime.getRuntime().exec("route print");
//Reads the output of the command
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null)
{
System.out.println(line);
}
//Closes the reader and waits for the process to finish
reader.close();
process.waitFor();
}
catch (IOException | InterruptedException e)
{
e.printStackTrace();
}
}
}