URLConnection getPermission Example

URLConnection class getPermission example. This example shows you how to use getPermission method.


URLConnection class getPermission example. public Permission getPermission() throws IOException Returns a permission object representing the permission necessary to make the connection represented by this object. This method returns null if no permission is required to make the connection.

Here is the code
/*
 * @ # GetPermission.java
 * A class repersenting use to GetPermission method 
 * of URL class in java.net package
 * version 24 June 2008
 * author Rose India 
 */

import java.net.*;
import java.security.*;

public class GetPermission {

    public static void main(String args[]) throws Exception {

        SocketAddress socketAddress =
                new InetSocketAddress("192.168.10.80"9090);
        Proxy proxy = new Proxy(Proxy.Type.HTTP, socketAddress);

        URL url = new URL("http://google.com");
        URLConnection connection = url.openConnection(proxy);
        Permission permission = connection.getPermission();

        System.out.println("permission name : " + permission.getName());
        System.out.println("permission action : " + permission.getActions());
    }
}

Output
permission name : google.com:80
permission action : connect,resolve

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US