URLPermission getActions() in Java

getActions(): This method is available in the java.net.URLPermission class of Java.

Syntax:

String java.net.URLPermission.getActions()

This method returns the normalized method list and requests a header list, in the form: "method-names: header-names"

where method-names are the list of methods separated by commas and header-names are the list of permitted headers separated by commas. There is no white space in the returned String. If header-names is empty then the colon separator may not be present.

Parameters: NA

Returns: the actions of this Permission.

Exceptions: NA

Approach

Java

package com.URLPermission;

import java.net.URLPermission;

public class URLPermissiongetActions {
    public static void main(String[] args) {

        String url = "https://beingcodeexpert.blogspot.com/";
        String actions = "read";
        URLPermission urlPermission = new URLPermission(url, actions);

        System.out.println(urlPermission.getActions());
    }
}

Output:

READ:


Some other methods of URLPermission class

URLPermission(String)This method creates a URLPermission with the given url string and unrestricted methods and requests headers by invoking the two-argument constructor as follows: URLPermission(url, "*:*")

URLPermission(String, String)This method creates a new URL permission from a url string and permits the given request methods and user-settable request headers.

equals(Object)his method returns true if, this.getActions().equals(p.getActions())and p's url equals this's url. Returns false otherwise.

getActions()This method returns the normalized method list and requests a header list, in the form: "method-names: header-names".

hashCode()This method returns a hashcode calculated from the hashcode of the actions String and the url string.

implies(Permission)This method checks if this URLPermission implies some of the permissions.

No comments:

Post a Comment