system load_Java System类load()方法及示例

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值