I have code:
import java.io.IOException;
import java.io.InputStream;
public class ExecuteDOSCommand {
public static void main(String[] args) {
final String dosCommand = "lsof -i: 8080";
try {
final Process process = Runtime.getRuntime().exec(dosCommand);
final InputStream in = process.getInputStream();
int ch;
while((ch = in.read()) != -1) {
System.out.print((char)ch);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
It's output:
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
java 1234 root 123 IPv6 819768 TCP *:8080 (LISTEN)
I want to get PID=1234, how do i do?:bowl::bowl::bowl::bowl:
import java.io.IOException;
import java.io.InputStream;
public class ExecuteDOSCommand {
public static void main(String[] args) {
final String dosCommand = "lsof -i: 8080";
try {
final Process process = Runtime.getRuntime().exec(dosCommand);
final InputStream in = process.getInputStream();
int ch;
while((ch = in.read()) != -1) {
System.out.print((char)ch);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
It's output:
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
java 1234 root 123 IPv6 819768 TCP *:8080 (LISTEN)
I want to get PID=1234, how do i do?:bowl::bowl::bowl::bowl: