devxlogo

Change the Read-only Permissions of a File (JDK 1.2.2)

Change the Read-only Permissions of a File (JDK 1.2.2)

Use this code to change the read-only permissions of a file in JDK 1.2.2:

public void changeFilePermission(){    String osName = System.getProperty("os.name");    try{        if (osName.equalsIgnoreCase("WINDOWS NT") ||osName.equals("Windows 2000") ) {          	Runtime.getRuntime().exec("cmd.exe /c attrib -r *.*");        }else{          	Process Proc = Runtime.getRuntime().exec("command.com /Cattrib -r *.*");        }        Thread.currentThread().sleep(100);    }catch(Exception e){        System.out.println(e.getMessage());    }  }

devx-admin

Share the Post: