我写了一个 java 程序来运行带有 http 8080 的 ngrok 。成功执行 ngrok.exe 后出现跟随错误。如何获取特定输出并在控制台中打印而不是整个输出?
String[] command = {
"src/Ngrok/ngrok.exe",
"src/Ngrok/ngrok.exe http 8080"
};
String line;
Process p;
BufferedReader input = null;
try {
p = Runtime.getRuntime().exec(command);
input = new BufferedReader(
new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
logsStatus.replaceSelection(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (null != input) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
按以下方式输出 && 错误
NAME:
ngrok - tunnel local ports to public URLs and inspect traffic
COMMANDS:
authtoken save authtoken to configuration file
credits prints author and licensing information
http start an HTTP tunnel
start start tunnels by name from the configuration file
tcp start a TCP tunnel
tls start a TLS tunnel
update update ngrok to the latest version
version print the version string
help Shows a list of commands or help for one command
错误是这样的:
ERROR: Unrecognized command: src/Ngrok/ngrok.exe http 8080
慕森王
相关分类