******************************************************************
COMPLETE SOURCE CODE FOR : SetFileReadOnly.java
******************************************************************
import java.io.File;
public class SetFileReadOnly
{
public static void main(String[]args)
{
File myFile=new File("MyFile.txt");
//Set MyFile.txt to Read-only
myFile.setReadOnly();
}
}
******************************************************************
JUST COMPILE AND EXECUTE IT
******************************************************************
Click here to download MyFile.txt
Note : Put MyFile.txt with java file above at the same location.