zoukankan      html  css  js  c++  java
  • 在上传前探测磁盘是否挂载正常

        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);
        }
  • 相关阅读:
    腾讯云CentOS7学习
    听力词汇发音练习软件
    中缀表达式转后缀表达式
    两个升序序列的中位数
    CentOS配置静态IP
    一种简单的基于图像或激光雷达的道路(赛道)识别程序
    Win10+VS2019 配置YOLOv3
    【算法题】CCF CSP第二题练习(更新中)
    rpm的使用
    SCL
  • 原文地址:https://www.cnblogs.com/littlehb/p/11071818.html
Copyright © 2011-2022 走看看