Busybox의 버전을 어떻게 알 수 있습니까? 인터넷 검색이 코드를 찾았습니다.비지 박스 버전 가져 오기 : 수행 방법?
public void busybox()throws IOException
{
/*
* If the busybox process is created successfully,
* then IOException won't be thrown. To get the
* busybox version, we must read the output of the command
*
*/
TextView z = (TextView)findViewById(R.id.busyboxid);
String line=null;char n[]=null;
try
{
Process p =Runtime.getRuntime().exec("busybox");
InputStream a = p.getInputStream();
InputStreamReader read = new InputStreamReader(a);
BufferedReader in = new BufferedReader(read);
/*
* Labeled while loop so that the while loop
* can be directly broken from the nested for.
*
*/
abc :while((line=in.readLine())!=null)
{
n=line.toCharArray();
for(char c:n)
{
/*
* This nested for loop checks if
* the read output contains a digit (number),
* because the expected output is -
* "BusyBox V1.xx". Just to make sure that
* the busybox version is read correctly.
*/
if(Character.isDigit(c))
{
break abc;//Once a digit is found, terminate both loops.
}
}
}
z.setText("BUSYBOX INSTALLED - " + line);
}
그러나 너무 상세한 아웃풋을 반환합니다. 나는 덜 세부적인 부분에만 관심이있다. 예를 들어 1.21.1과 같은 버전이다. 어떻게해야합니까?