system load
系统类load()方法 (System class load() method)
load() method is available in java.lang package.
load()方法在java.lang包中可用。
load() method is used to load the java file with the given parameter named fn(filename) from a local file system.
load()方法用于从本地文件系统中加载名为fn(filename)的给定参数的Java文件。
load() method is a static method, it is accessible with the class name too.
load()方法是静态方法,也可以使用类名进行访问。
load() method may throw an exception at the time of file loading:
load()方法在文件加载时可能会引发异常:
- SecurityException: In this exception, its checkLink() method does not allow load the specified file as passed in the method when the security manager exists.SecurityException :在此异常中,当安全管理器存在时,其checkLink()方法不允许加载在该方法中传递的指定文件。
- UnsatisfiedLinkError: In this exception, if the loaded file does not exists in the library.UnsatisfiedLinkError :在此异常中,如果库中不存在已加载的文件。
- NullPointerException: In this exception, if the loaded file name is null.NullPointerException :在此异常中,如果加载的文件名为null。
Syntax:
句法:
public static void load(String fn);
Parameter(s):
参数:
String fn – represents the name of the file with complete file path.
字符串fn –代表具有完整文件路径的文件名。
Return value:
返回值:
The return type of this method is void, it does not return anything.
此方法的返回类型为void ,它不返回任何内容。
Example:
例:
// Java program to demonstrate the example of
// load() method of System Class
public class LoadMethod {
public static void main(String[] args) {
// load a library FP30TXT.dll that is in Windows/system folder
System.out.println(" Process of Library Loading ");
Runtime.getRuntime().load("C:/Windows/system/FP30TXT.dll");
System.out.println("Process of Library Loading completion");
}
}
Output
输出量
E:\Programs>javac LoadMethod.java
E:\Programs>java LoadMethod
Process of Library Loading
Process of Library Loading completion
翻译自: https://www.includehelp.com/java/system-class-load-method-with-example.aspx
system load