extends SecurityManager : SecurityManager « Security « Java Tutorial

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);

36.41.1.extends SecurityManager
36.41.2.Use SecurityManager to check AWT permission and file permission
36.41.3.Listing All Permissions Granted to Classes Loaded from a URL or Directory
36.41.4.Define your own security manager
36.41.5.Enabling the Security Manager
36.41.6.To specify an additional policy file, set the java.security.policy system property at the command line:
36.41.7.To ignore the policies in the java.security file, and use the specified policy, use '==' instead of '='