當前位置: 首頁>>代碼示例>>Java>>正文


Java System.getProperty方法代碼示例

本文整理匯總了Java中java.lang.System.getProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java System.getProperty方法的具體用法?Java System.getProperty怎麽用?Java System.getProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.System的用法示例。


在下文中一共展示了System.getProperty方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testStreamZip

import java.lang.System; //導入方法依賴的package包/類
@Test
public void testStreamZip() throws IOException {
    try (ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."), "input.zip"))) {
        zf.stream().forEach(e -> assertTrue(e instanceof ZipEntry));
        zf.stream().forEach(e -> assertEquals(e.toString(), "ReadZip.java"));

        Object elements[] = zf.stream().toArray();
        assertEquals(1, elements.length);
        assertEquals(elements[0].toString(), "ReadZip.java");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:StreamZipEntriesTest.java

示例2: getUserName

import java.lang.System; //導入方法依賴的package包/類
private String getUserName() {
    String usr = null;

    try {
        usr = System.getProperty("user.name");
    } catch (Exception e) {
    }
    return usr;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:10,代碼來源:TestDynamicPolicy.java

示例3: testStreamJar

import java.lang.System; //導入方法依賴的package包/類
@Test
public void testStreamJar() throws IOException {
    try (JarFile jf = new JarFile(new File(System.getProperty("test.src", "."), "input.jar"))) {
        jf.stream().forEach(e -> assertTrue(e instanceof JarEntry));

        Object elements[] = jf.stream().toArray();
        assertEquals(3, elements.length);
        assertEquals(elements[0].toString(), "META-INF/");
        assertEquals(elements[1].toString(), "META-INF/MANIFEST.MF");
        assertEquals(elements[2].toString(), "ReleaseInflater.java");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:StreamZipEntriesTest.java

示例4: testClosedZipFile

import java.lang.System; //導入方法依賴的package包/類
@Test
public void testClosedZipFile() throws IOException {
    ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."), "input.zip"));
    zf.close();
    try {
        Stream s = zf.stream();
        fail("Should have thrown IllegalStateException");
    } catch (IllegalStateException e) {
        // expected;
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:12,代碼來源:StreamZipEntriesTest.java

示例5: testClosedJarFile

import java.lang.System; //導入方法依賴的package包/類
@Test
public void testClosedJarFile() throws IOException {
    JarFile jf = new JarFile(new File(System.getProperty("test.src", "."), "input.jar"));
    jf.close();
    try {
        Stream s = jf.stream();
        fail("Should have thrown IllegalStateException");
    } catch (IllegalStateException e) {
        // expected;
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:12,代碼來源:StreamZipEntriesTest.java

示例6: findTestsInteropDir

import java.lang.System; //導入方法依賴的package包/類
static private File findTestsInteropDir()
{
    File f = new File(System.getProperty("user.dir"));
    while (f != null && !f.getName().equals("tests"))
        f = f.getParentFile();
    if (f != null && f.isDirectory())
        return new File(f, "interop");
    else
        throw new Error("Cannot find tests/interop directory");
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:11,代碼來源:InteropTest.java

示例7: init

import java.lang.System; //導入方法依賴的package包/類
public void init() {
    //Create instructions for the user here, as well as set up
    // the environment -- set the layout manager, add buttons,
    // etc.
    this.setLayout(new BorderLayout());

    try {
        String testFilePath = System.getProperty("test.classes");
        FileWriter testHTML = null;
        try {
            testHTML = new FileWriter(testFilePath + "/" + TEST_HTML_NAME);
            testHTML.write("<html>\n" +
                    "<head>\n" +
                    "<title>KeyReleasedInAppletTest </title>\n" +
                    "</head>\n" +
                    "<body>\n" +
                    "<h1>KeyReleasedInAppletTest<br>Bug ID:8010009 </h1>\n" +
                    "<p>Make sure the applet is focuced and type any character on the keyboard. <br>"+
                    "The applet should show keyPressed, keyTyped and keyReleased messages.</p>\n" +
                    "<APPLET CODE=\"TestApplet.class\" WIDTH=400 HEIGHT=200></APPLET>\n" +
                    "</body>");
        } finally {
            if (testHTML != null) {
                testHTML.close();
            }
        }

        String[] instructions =
                {
                        "(1) Install the tested JDK to be used by the Java Plugin.\n",
                        "(2) Open Java Preferences and set security level to minimal.\n",
                        "(3) Open the " + TEST_HTML_NAME + " in Firefox in firefox web browser\n" +
                                " It is located at: " + testFilePath,
                        "(5) Continue the test according to the instructions in the applet.\n",
                };
        Sysout.createDialogWithInstructions(instructions);
    } catch (Throwable e) {
        //Fail the test.
        throw new RuntimeException(e.getMessage());
    }

}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:43,代碼來源:KeyReleasedInAppletTest.java

示例8: supportsSimulation

import java.lang.System; //導入方法依賴的package包/類
public static boolean supportsSimulation() {
	String os = System.getProperty("os.name");
	//for now this is good enough, but we still need better handling if they have this OS but have not installed FRCSim
	//return (os.equals("Windows 8") || os.equals("Windows 7") || os.equals("Linux") || os.equals("Windows 8.1"));
	return os.equals("Linux") || os.startsWith("Mac OS");
}
 
開發者ID:wpilibsuite,項目名稱:EclipsePlugins,代碼行數:7,代碼來源:SimulationNotification.java


注:本文中的java.lang.System.getProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。