extends SecurityManager
import java.io.IOException; public class MainClass { public static void main(String args[]) throws IOException { System.setSecurityManager(new MySecurityManager()); } } class MySecurityManager extends SecurityManager { public void checkRead(String file) { if (!(file.endsWith(".txt")) && !(file.endsWith(".java")) && !(file.endsWith(".class")) && !(file.startsWith("C:\\"))) { throw new SecurityException("No Read Permission for : " + file); } } }