Home » Java programming language

Java FilePermission getActions() Method with Example

FilePermission Class getActions() method: Here, we are going to learn about the getActions() method of FilePermission Class with its syntax and example.
Submitted by Preeti Jain, on April 02, 2020

FilePermission Class getActions() method

  • getActions() method is available in java.io package.
  • getActions() method is used to check whether this FilePermission and the given object are equal or not in terms of pathname and actions like read, write, delete, execute, delete, etc.
  • getActions() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
  • getActions() method does not throw an exception at the time of getting actions.

Syntax:

    public String getActions();

Parameter(s):

  • It does not accept any parameter.

Return value:

The return type of the method is String, it returns the canonical (some authorised) denotations of the actions.

Example:

// Java program to demonstrate the example 
// of String getActions() method 
// of FilePermission

import java.io.*;

public class GetActionsOfFP {
 public static void main(String[] args) throws Exception {
  FilePermission fp1 = null;
  FilePermission fp2 = null;

  try {
   // Instantiates FilePermission fp1 , fp2 
   fp1 = new FilePermission("D:\\includehelp.txt", "read");
   fp2 = new FilePermission("D:\\includehelp.txt", "write");

   // By using getActions() method is to return
   // the action performed on the file of the 
   // FilePermission
   String action = fp1.getActions();
   System.out.println("fp1.getActions(): " + action);

   action = fp2.getActions();
   System.out.println("fp2.getActions(): " + action);

  } catch (Exception ex) {
   System.out.println(ex.toString());
  }
 }
}

Output

fp1.getActions(): read
fp2.getActions(): write





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.