AccessTest.java Source code

Java tutorial

Introduction

Here is the source code for AccessTest.java

Source

import java.net.SocketPermission;
import java.security.AccessControlException;
import java.security.AccessController;

public class AccessTest {
    public static void main(String[] a) {
        SocketPermission sp = new SocketPermission("www.java2s.com", "connect");
        try {
            AccessController.checkPermission(sp);
            System.out.println("Ok to open socket");
        } catch (AccessControlException ace) {
            System.out.println(ace);
        }
    }
}