newPermissionCollection(): This method is available in the java.net.SocketPermission class of Java.
Syntax:
PermissionCollection java.net.SocketPermission.newPermissionCollection()
This method returns a new PermissionCollection object for storing SocketPermission objects.
SocketPermission objects must be stored in a manner that allows them to be inserted into the collection in any order, but that also enables the PermissionCollection implies method to be implemented in an efficient (and consistent) manner.
Parameters: NA
Returns: a new PermissionCollection object suitable for storing SocketPermissions.
Exceptions: NA
Approach
Java
package com.SocketPermission;import java.net.SocketPermission;public class SocketPermissionnewPermissionCollection {public static void main(String[] args) {String host = "google.com";String action = "connect";SocketPermission socketPermission = new SocketPermission(host, action);System.out.println(socketPermission.newPermissionCollection());}}
Output:
java.net.SocketPermissionCollection@3830f1c0 (
)
Some other methods of SocketPermission
SocketPermission(String, String): This method creates a new SocketPermission object with the specified actions. The host is expressed as a DNS name, or as a numerical IP address.
equals(Object): This method checks two SocketPermission objects for equality.
getActions(): This method returns the canonical string representation of the actions. Always returns present actions in the following order: connect, listen, accept, resolve.
hashCode(): This method returns the hash code value for this object.
implies(Permission): This method checks if this socket permission object "implies" the specified permission.
newPermissionCollection(): This method returns a new PermissionCollection object for storing SocketPermission objects.
No comments:
Post a Comment