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

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist