Java.io.FilePermission.getActions() Method

Advertisements


Description

The java.io.FileOutputStream.getActions() method returns the "canonical string representation" of the actions. This means, the method always returns actions in the following order: read, write, execute, delete, readlink. E.g., if this FilePermission object allows both write and read actions, a invoke to getActions will return the string "read,write".

Declaration

Following is the declaration for java.io.FilePermission.getActions() method:

public String getActions()

Parameters

  • NA

Return Value

This method returns the canonical string representation of the actions.

Exception

  • NA

Example

The following example shows the usage of java.io.FilePermission.getActions() method.

package com.tutorialspoint;

import java.io.FilePermission;
import java.io.IOException;

public class FilePermissionDemo {
   public static void main(String[] args) throws IOException {
      
      FilePermission fp = null;
      
      try{
         // create new file permissions
         fp=new FilePermission("C://test.txt", "read");
         
         // the canonical string representation of the action
         String s = fp.getActions();
         
         // prints
         System.out.print("Action: "+s);
         
      }catch(Exception ex){
         // if an error occurs
         ex.printStackTrace();
      }
   }
}

Let us compile and run the above program, this will produce the following result:

Action: read



Advertisements
Advertisements