package test;
import jdk.internal.org.objectweb.asm.tree.analysis.Value;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
class enhm {
public static void getenam() throws IOException {
List commands = new ArrayList<>();
commands.add("tshark");
commands.add("-r");
commands.add("F:\\bao\\ipsec.pcap");
commands.add("-O");
commands.add("isakmp");
commands.add("-Y");
commands.add("isakmp");
commands.add("-T");
commands.add("fields");
commands.add("-e");
commands.add("isakmp.ike.attr.encryption_algorithm");
ProcessBuilder tshark = new ProcessBuilder(commands);
Process process = tshark.start();
BufferedReader bfReader1 = new BufferedReader(new InputStreamReader(process.getInputStream()));
String encryption_algorithm = bfReader1.readLine();
if (encryption_algorithm==null){
System.out.println();
}
else{
System.out.println("加密算法的值为:"+encryption_algorithm);
}
}
}
public class gg {
public static void main(String[] args) {
enhm za= new enhm();
try {
za.getenam();
} catch (IOException e) {
e.printStackTrace();
}
}
}
输出结果:
加密算法的值为:128
我想输出这个command命令里面最后一行的那个值,但是这个值并不是只有一个,为什么只能输出一个啊。理想结果应该是有多少个值就输出多少个加密算法的值是多少
String encryption_algorithm = bfReader1.readLine();
你只读了一行,当然只有一个了
你想有多少读多少,要么找找它有没有readLines方法
要么循环一直读到没数据了为止