How to make a file read only in Java ?

In this tutorial, we will see How to Make a file read only in Java.

We will use setReadOnly() method from File class to make a file read only in Java. setReadOnly() method returns a boolean value which can be used to verify whether the file has become read only or not. We will use canWrite() method to check if the file is read only or not.

Output:

You can also learn about

Related posts

Leave a Comment