本文整理汇总了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");
}
}
示例2: getUserName
import java.lang.System; //导入方法依赖的package包/类
private String getUserName() {
String usr = null;
try {
usr = System.getProperty("user.name");
} catch (Exception e) {
}
return usr;
}
示例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");
}
}
示例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;
}
}
示例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;
}
}
示例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");
}
示例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());
}
}
示例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");
}