Set file to Read-only in java

Complete source code below will show you, how to set a file to Read-only in java.

******************************************************************
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.

RELAXING NATURE VIDEO