Before uploading to detect whether the disk is mounted correctly

    public  void getMountInfo () throws IOException {
         / * 
        Office version: Upload disk resources there are two cases, one is disk resources on the windows, and the other is on the linux disk resources, 
        resources need to check on whether linux off disc, only the windows need to be checked before uploading, not by not uploading. 
        Is on linux or windows, you can set a global variable to identify. 
        * / 
        String Command = "DF -KH" ; 
        Process Pro; 
        the Runtime Runtime = Runtime.getRuntime (); 
        Pro = Runtime.exec (Command); 
        the BufferedReader INPUT = new new the BufferedReader ( new new the InputStreamReader (pro.getInputStream ())); 
        the PrintWriter the 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 (); 
        the JSONObject Jo = new new the JSONObject (); 
        jo.put ( "Success" , HaveMountPointDisk);
         IF (HaveMountPointDisk) 
        { 
            jo.put ( "Message", "Normal mounted disk!" ); 
        } 
        the else 
        { 
            jo.put ( "the Message", "mount disk abnormalities, can not upload a file!" ); 
        } 
        renderJson (Jo); 
    }

 

Guess you like

Origin www.cnblogs.com/littlehb/p/11071818.html