Java FilePermission getActions() Example
FilePermission class getActions() method example. This example shows you how to use getActions() method.
Syntax is : public String getActions()
Method returns the "canonical string representation" of the actions. That is, this method always returns present actions in the following
order: read, write, execute, delete. For example, if this FilePermission object allows both write and read actions, a call to getActions will
return the string "read,write".
Here is the code.
/**
* @(#) GetActionsFilePermission.java
* A class representing use of method getActions() of FilePermission
class in java.io Package.
* @Version 08-June-2008
* @author Rose India Team
*/
import java.io.*;
public class GetActionsFilePermission {
public static void main(String[] args) throws IOException {
// create object of FilePermission class.
FilePermission objFP1 = new FilePermission("Mahendra.txt","read");
FilePermission objFP2 = new FilePermission("file.txt","execute");
FilePermission objFP3 = new FilePermission("file1.txt","write");
// getAction() method call.
String action = objFP1.getActions();
System.out.println("action for the file Mahendra.txt is : " + action);
action = objFP2.getActions();
System.out.println("action for the file file.txt is : " + action);
action = objFP3.getActions();
System.out.println("action for the file file1.txt is : " + action);
}
} |
Output of the program.
action for the file Mahendra.txt is : read
action for the file file.txt is : execute
action for the file file1.txt is : write |
|