类java.lang.System源码实例Demo

下面列出了怎么用java.lang.System的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: TencentKona-8   文件: DefaultValue.java
public static void main(String[] args) throws Exception {
    boolean endResult = true;

    if (!arePaddedPairwise(R1.class, "int1", "int2")) {
        System.err.println("R1 failed");
        endResult &= false;
    }

    if (!arePaddedPairwise(R2.class, "int1", "int2")) {
        System.err.println("R2 failed");
        endResult &= false;
    }

    if (!arePaddedPairwise(R3.class, "int1", "int2")) {
        System.err.println("R3 failed");
        endResult &= false;
    }

    System.out.println(endResult ? "Test PASSES" : "Test FAILS");
    if (!endResult) {
       throw new Error("Test failed");
    }
}
 
源代码2 项目: javapoet   文件: TypeSpecTest.java
@Test public void indexedElseIf() throws Exception {
  TypeSpec taco = TypeSpec.classBuilder("Taco")
      .addMethod(MethodSpec.methodBuilder("choices")
          .beginControlFlow("if ($1L != null || $1L == $2L)", "taco", "otherTaco")
          .addStatement("$T.out.println($S)", System.class, "only one taco? NOO!")
          .nextControlFlow("else if ($1L.$3L && $2L.$3L)", "taco", "otherTaco", "isSupreme()")
          .addStatement("$T.out.println($S)", System.class, "taco heaven")
          .endControlFlow()
          .build())
      .build();
  assertThat(toString(taco)).isEqualTo(""
      + "package com.squareup.tacos;\n"
      + "\n"
      + "import java.lang.System;\n"
      + "\n"
      + "class Taco {\n"
      + "  void choices() {\n"
      + "    if (taco != null || taco == otherTaco) {\n"
      + "      System.out.println(\"only one taco? NOO!\");\n"
      + "    } else if (taco.isSupreme() && otherTaco.isSupreme()) {\n"
      + "      System.out.println(\"taco heaven\");\n"
      + "    }\n"
      + "  }\n"
      + "}\n");
}
 
源代码3 项目: hottub   文件: DefaultValue.java
public static void main(String[] args) throws Exception {
    boolean endResult = true;

    if (!arePaddedPairwise(R1.class, "int1", "int2")) {
        System.err.println("R1 failed");
        endResult &= false;
    }

    if (!arePaddedPairwise(R2.class, "int1", "int2")) {
        System.err.println("R2 failed");
        endResult &= false;
    }

    if (!arePaddedPairwise(R3.class, "int1", "int2")) {
        System.err.println("R3 failed");
        endResult &= false;
    }

    System.out.println(endResult ? "Test PASSES" : "Test FAILS");
    if (!endResult) {
       throw new Error("Test failed");
    }
}
 
源代码4 项目: java-example   文件: LayoutFrame.java
private void setHasFrame(JFrame frame, boolean hasFrame) {
	if (!this.frameless) {
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				System.out.println(windowName + " hasFrame=" + hasFrame);
				WinDef.HWND hWnd = new WinDef.HWND();
				hWnd.setPointer(Native.getComponentPointer(frame));
				LayoutFrame.this.externalWindowObserver.setHasFrame(hWnd, hasFrame);
				frame.setResizable(hasFrame);
				frame.invalidate();
				frame.validate();
				frame.repaint();
				SwingUtilities.updateComponentTreeUI(frame);
			}
		});
	}
}
 
源代码5 项目: JarBundler   文件: PropertyListWriter.java
private void writeJavaProperties(Hashtable javaProperties, Node appendTo)
{

    writeKey("Properties", appendTo);

    Node propertiesDict = createNode("dict", appendTo);

    for (Iterator i = javaProperties.keySet().iterator(); i.hasNext(); )
    {
        String key = (String) i.next();

        if (key.startsWith("com.apple.") && (bundleProperties.getJavaVersion() >= 1.4))
        {
            System.out.println("Deprecated as of 1.4: " + key);
            continue;
        }

        writeKeyStringPair(key, (String) javaProperties.get(key), propertiesDict);
    }
}
 
源代码6 项目: javapoet   文件: TypeSpecTest.java
@Test public void elseIf() throws Exception {
  TypeSpec taco = TypeSpec.classBuilder("Taco")
      .addMethod(MethodSpec.methodBuilder("choices")
          .beginControlFlow("if (5 < 4) ")
          .addStatement("$T.out.println($S)", System.class, "wat")
          .nextControlFlow("else if (5 < 6)")
          .addStatement("$T.out.println($S)", System.class, "hello")
          .endControlFlow()
          .build())
      .build();
  assertThat(toString(taco)).isEqualTo(""
      + "package com.squareup.tacos;\n"
      + "\n"
      + "import java.lang.System;\n"
      + "\n"
      + "class Taco {\n"
      + "  void choices() {\n"
      + "    if (5 < 4)  {\n"
      + "      System.out.println(\"wat\");\n"
      + "    } else if (5 < 6) {\n"
      + "      System.out.println(\"hello\");\n"
      + "    }\n"
      + "  }\n"
      + "}\n");
}
 
源代码7 项目: Rholang   文件: Main.java
/***************************************************************
   Function: pset
   **************************************************************/
 private void pset
   (
    Vector dtrans_group
    )
     {
int i;
int size;
CDTrans dtrans;

size = dtrans_group.size();
for (i = 0; i < size; ++i)
  {
    dtrans = (CDTrans) dtrans_group.elementAt(i);
    System.out.print(dtrans.m_label + " ");
  }
     }
 
源代码8 项目: buffer_bci   文件: CursorStim.java
public void display(){
     JFrame frame = new JFrame("Cursor Stim");
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 frame.setTitle("Cursor Stim");
     frame.getContentPane().add(this, BorderLayout.CENTER);
 frame.pack();
     frame.setVisible(true);
     
     // start the experiment controller thread
     startControllerThread();
     
     // run the main-loop rendering loop
     renderloop();
     
 // run the experiment
 frame.dispose();
 System.exit(0);
}
 
源代码9 项目: bcm-android   文件: ArrayListCursor.java
@SuppressWarnings({"unchecked"})
public ArrayListCursor(String[] columnNames, ArrayList<ArrayList> rows) {
    int colCount = columnNames.length;
    boolean foundID = false;
    // Add an _id column if not in columnNames
    for (int i = 0; i < colCount; ++i) {
        if (columnNames[i].compareToIgnoreCase("_id") == 0) {
            mColumnNames = columnNames;
            foundID = true;
            break;
        }
    }

    if (!foundID) {
        mColumnNames = new String[colCount + 1];
        System.arraycopy(columnNames, 0, mColumnNames, 0, columnNames.length);
        mColumnNames[colCount] = "_id";
    }

    int rowCount = rows.size();
    mRows = new ArrayList[rowCount];

    for (int i = 0; i < rowCount; ++i) {
        mRows[i] = rows.get(i);
        if (!foundID) {
            mRows[i].add(i);
        }
    }
}
 
源代码10 项目: openjdk-jdk9   文件: TestDynamicPolicy.java
public static void main(String args[]) throws Exception {

        try {
            //
            TestDynamicPolicy jstest = new TestDynamicPolicy();
            jstest.doit();
        } catch(Exception e)  {
            System.out.println("Failed. Unexpected exception:" + e);
            throw e;
        }
        System.out.println("Passed. OKAY");
    }
 
源代码11 项目: hottub   文件: TestDynamicPolicy.java
private String getUserName() {
    String usr = null;

    try {
        usr = System.getProperty("user.name");
    } catch (Exception e) {
    }
    return usr;
}
 
源代码12 项目: jdk8u-dev-jdk   文件: TestDynamicPolicy.java
private String getUserName() {
    String usr = null;

    try {
        usr = System.getProperty("user.name");
    } catch (Exception e) {
    }
    return usr;
}
 
源代码13 项目: dragonwell8_jdk   文件: TestDynamicPolicy.java
private String getUserName() {
    String usr = null;

    try {
        usr = System.getProperty("user.name");
    } catch (Exception e) {
    }
    return usr;
}
 
源代码14 项目: jdk8u-jdk   文件: EarlyTimeout.java
public void run() {
    try {
        startedSignal.countDown();
        long start = System.nanoTime();
        reference = queue.remove(TIMEOUT);
        actual = NANOSECONDS.toMillis(System.nanoTime() - start);
    } catch (InterruptedException ex) {
        throw new RuntimeException(ex);
    }
}
 
源代码15 项目: javapoet   文件: JavaFileTest.java
private TypeSpec importStaticTypeSpec(String name) {
  MethodSpec method = MethodSpec.methodBuilder("minutesToSeconds")
      .addModifiers(Modifier.PUBLIC, Modifier.STATIC)
      .returns(long.class)
      .addParameter(long.class, "minutes")
      .addStatement("$T.gc()", System.class)
      .addStatement("return $1T.SECONDS.convert(minutes, $1T.MINUTES)", TimeUnit.class)
      .build();
  return TypeSpec.classBuilder(name).addMethod(method).build();

}
 
源代码16 项目: hottub   文件: StreamZipEntriesTest.java
@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;
    }
}
 
源代码17 项目: openjdk-jdk9   文件: EarlyTimeout.java
public void run() {
    try {
        startedSignal.countDown();
        long start = System.nanoTime();
        reference = queue.remove(TIMEOUT);
        actual = NANOSECONDS.toMillis(System.nanoTime() - start);
    } catch (InterruptedException ex) {
        throw new RuntimeException(ex);
    }
}
 
源代码18 项目: dragonwell8_jdk   文件: StreamZipEntriesTest.java
@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;
    }
}
 
源代码19 项目: jdk8u-dev-jdk   文件: StreamZipEntriesTest.java
@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;
    }
}
 
源代码20 项目: jdk8u-dev-jdk   文件: StreamZipEntriesTest.java
@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");
    }
}
 
源代码21 项目: Rholang   文件: Main.java
private void new_block(int idx, int bnum) {
if (size==bits.length) { // resize
    long[] nbits = new long[size*3];
    int [] noffs = new int [size*3];
    System.arraycopy(bits, 0, nbits, 0, size);
    System.arraycopy(offs, 0, noffs, 0, size);
    bits = nbits;
    offs = noffs;
}
CUtility.ASSERT(size<bits.length);
insert_block(idx, bnum);
   }
 
源代码22 项目: jdk8u-jdk   文件: StreamZipEntriesTest.java
@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;
    }
}
 
源代码23 项目: TencentKona-8   文件: StreamZipEntriesTest.java
@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;
    }
}
 
源代码24 项目: jdk8u-jdk   文件: TestDynamicPolicy.java
private String getUserName() {
    String usr = null;

    try {
        usr = System.getProperty("user.name");
    } catch (Exception e) {
    }
    return usr;
}
 
源代码25 项目: jdk8u-jdk   文件: TestDynamicPolicy.java
public static void main(String args[]) throws Exception {

        try {
            //
            TestDynamicPolicy jstest = new TestDynamicPolicy();
            jstest.doit();
        } catch(Exception e)  {
            System.out.println("Failed. Unexpected exception:" + e);
            throw e;
        }
        System.out.println("Passed. OKAY");
    }
 
源代码26 项目: hottub   文件: EarlyTimeout.java
public void run() {
    try {
        startedSignal.countDown();
        long start = System.nanoTime();
        reference = queue.remove(TIMEOUT);
        actual = NANOSECONDS.toMillis(System.nanoTime() - start);
    } catch (InterruptedException ex) {
        throw new RuntimeException(ex);
    }
}
 
源代码27 项目: openjdk-8-source   文件: StreamZipEntriesTest.java
@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;
    }
}
 
源代码28 项目: openjdk-8-source   文件: StreamZipEntriesTest.java
@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");
    }
}
 
源代码29 项目: dev-summit-architecture-demo   文件: PostTest.java
@Test(expected = ValidationFailedException.class)
public void emptyCustomId() {
    Post post = new Post();
    post.setUserId(1);
    post.setClientId(null);
    post.setText("abc");
    post.setCreated(System.currentTimeMillis());
    post.validate();
}
 
源代码30 项目: java-example   文件: LayoutFrame.java
public void cleanup() {
	try {
		System.out.println(windowName + " cleaning up ");
		this.externalWindowObserver.dispose();
	}
	catch (Exception e) {
		e.printStackTrace();
	}
}
 
 类所在包
 同包方法