두 줄 번호 사이의 텍스트를 제거하려고합니다. 나는 정말로 긴 명령입니다 우분투에서 dmesg
를 사용하고, 그래서 라인 0 ~ 3 사이의 문자열을 트리밍 좋아하지만 4-5을 떠날 것 등이 여기에 내 코드입니다 :Java - 줄 사이의 텍스트 제거
try {
Process terminal = Runtime.getRuntime().exec("dmesg");
BufferedReader in = new BufferedReader(new InputStreamReader(terminal.getInputStream()));
String line;
String output = "";
while((line = in.readLine()) != null) {
output += line + "\n";
}
System.out.println(output);
in.close();
} catch(Exception exc) {
System.err.println("An error occurred while executing a command in the terminal. Error:\n" + exc);
}
어떤 제안이? 감사!
나는 코드가 당신이 줄을 제거하려고했다 표시되지 않습니다. 내가 보는 모든 것은 선을 읽는 코드입니다. 라인을 읽을 때마다 증가하는 라인 카운터를 만들 수 있습니다. 그 다음에는 3보다 큰 행만 윤곽을 나타냅니다. – camickr