A read-only file is any file with the read-only attribute. Read-only files can be opened and accessed but you will not be able to make changes to it. They can be deleted and moved. You can make a file read-only by using file.setReadOnly() method of File class. After using this method, you will not be able to write or edit into the file.
Here is the code:
import java.io.File;
|
The above program will make a the file read only
To make file read only file.setReadOnly(); method is used.
In the page you learned how to make a file read only.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.