onetoone.java

来自「jni java本地接口编程例子原代码,是java调用本地操作系统代码的接口」· Java 代码 · 共 33 行

JAVA
33
字号
class C {
    public static native int atol(String str);
}

class Win32 {
    public static native int CreateFile(
        String fileName,          // file name
        int desiredAccess,        // access (read-write) mode 
        int shareMode,            // share mode 
        int[] secAttrs,           // security attributes 
        int creationDistribution, // how to create 
        int flagsAndAttributes,   // file attributes 
        int templateFile);        // file with attr. to copy
}

class OneToOne {
    public static void main(String[] args) {
	System.out.println("atol(\"123\") = " + C.atol("123"));
	System.out.println("Creating a file called TestFile.tst in the current directory...");
	Win32.CreateFile("TestFile.tst",
			 0x40000000, // GENERIC_WRITE
			 0,          // not sharable
			 null,       // no security
			 2,          // CREATE_ALWAYS
			 0x00000080, // FILE_ATTRIBUTE_NORMAL
			 0);         // no template file
    }
    static {
	System.loadLibrary("OneToOne");
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?