publicstaticvoidgetFreeSpace(Stringpath)throwsException{Processp=Runtime.getRuntime().exec("df -h /"+path);//Windows should add "cmd /c" at the fround of commandInputStreamreader=newBufferedInputStream(p.getInputStream());// StringBuffer buffer=new StringBuffer();//if use the StringBuffer, the// Chinese in output will be garbled.ByteArrayOutputStreambos=newByteArrayOutputStream();intc=-1;while((c=reader.read())!=-1){// buffer.append((char)c);bos.write(c);}// String output=buffer.toString();Stringoutput=bos.toString();System.out.println(output);}