Mark file or directory Read Only - Java File Path IO

Java examples for File Path IO:Directory

Description

Mark file or directory Read Only

Demo Code


import java.io.*;
 
public class Main {
 
  public static void main(String[] args) {
    File file = new File("C://Folder//demo.txt");
   /*from   w  w w  .j  a  v  a2 s  .c  o  m*/
     boolean blnMarked  = file.setReadOnly();
   
     System.out.println("Was file marked read only ?: " + blnMarked);

     System.out.println("Is file writable ?: " + file.canWrite());
  }
}

Result


Related Tutorials