title: Set the Read-only property of a File
body: <p>I am trying to set the read-only property of a File, but it doesn't seem to work. Could someone please help me to understand why.</p>
  
  <p>Here is my code...</p>
  
  <pre><code>public class Main {
      public static void main(String[] args) {
          File f = new File("c:/ulala.txt");
          if (!f.setReadOnly()) {
              System.out.println("Grrr! Can't set file read-only.");
              return;
          }
      }
  }
  </code></pre>