在上传前探测磁盘是否挂载正常

    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);
    }

 

转载于:https://www.cnblogs.com/littlehb/p/11071818.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值