public void getMountInfo() throws IOException {
/*
局版:上传的资源磁盘存在两种情况,一种是资源磁盘在windows上,另一种是资源磁盘在linux上,
资源在linux上的不需要检查是否掉盘,只有在windows上的需要在上传前进行检查,未通过不让上传。
是在linux还是windows上,可以设置一个全局变量来识别。
*/
String command = "df -kh";
Process pro;
Runtime runTime = Runtime.getRuntime();
pro = runTime.exec(command);
BufferedReader input = new BufferedReader(new InputStreamReader(pro.getInputStream()));
PrintWriter output = new PrintWriter(new OutputStreamWriter(pro.getOutputStream()));
String line;
boolean HaveMountPointDisk=false;
while ((line = input.readLine()) != null) {
String[] arr=line.split(" ");
if(arr.length>0 && arr[arr.length-1].equals("/usr/local/tomcat7/webapps/dsideal_yy/html/down"))
{
HaveMountPointDisk=true;
break;
}
}
input.close();
output.close();
pro.destroy();
JSONObject jo=new JSONObject();
jo.put("success",HaveMountPointDisk);
if(HaveMountPointDisk)
{
jo.put("message","磁盘挂载正常!");
}
else
{
jo.put("message","磁盘挂载异常,不能上传文件!");
}
renderJson(jo);
}