Java FilePermission暗含()方法与示例
FilePermission類implies()方法 (FilePermission Class implies() method)
implies() method is available in java.io package.
implies()方法在java.io包中可用。
implies() method is used to check whether this FilePermission implies the given permission (perm) or not.
implies()方法用于檢查此FilePermission是否隱含給定的權限(權限)。
implies() 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.
implies()方法是一個非靜態方法,僅可通過類對象訪問,如果嘗試使用類名訪問該方法,則會收到錯誤消息。
implies() method does not throw an exception at the time of implies the given permission.
implies()方法在隱含給定權限時不會引發異常。
Syntax:
句法:
public boolean implies(Permission perm);Parameter(s):
參數:
Permission perm – represents the permission object to be checked.
權限權限 –表示要檢查的權限對象。
Return value:
返回值:
The return type of the method is boolean, it returns true based on some statements:
該方法的返回類型為boolean ,它基于一些語句返回true :
When the given permission object is an instance of FilePermission.
當給定的權限對象是FilePermission的實例時。
When the given permission actions are a proper subset of this FilePermission object actions.
當給定的權限操作是此FilePermission對象操作的適當子集時。
When the pathname of the given permission object is implied by this FilePermission object pathname.
當此FilePermission對象的路徑名隱含給定權限對象的路徑名時。
Otherwise, it returns false.
否則,它返回false 。
Example:
例:
// Java program to demonstrate the example // of boolean implies(Permission perm) method // of FilePermissionimport java.io.*;public class ImpliesOfFP {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 implies() method is to check// whether this FilePermission implies the// given permission or notboolean status = fp1.implies(fp1);System.out.println("fp1.implies(fp1): " + status);status = fp2.implies(fp1);System.out.println("fp2.implies(fp1): " + status);} catch (Exception ex) {System.out.println(ex.toString());}} }Output
輸出量
fp1.implies(fp1): true fp2.implies(fp1): false翻譯自: https://www.includehelp.com/java/filepermission-implies-method-with-example.aspx
總結
以上是生活随笔為你收集整理的Java FilePermission暗含()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 键盘特殊_特殊键盘
- 下一篇: Java PrintWriter clo