Java Code Examples for java.net.URLClassLoader#getSystemResourceAsStream()

The following examples show how to use java.net.URLClassLoader#getSystemResourceAsStream() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassDumperTest.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testListInnerClasses() throws IOException {
  InputStream classFileInputStream = URLClassLoader.getSystemResourceAsStream(
      EXAMPLE_CLASS_FILE);
  ClassParser parser = new ClassParser(classFileInputStream, EXAMPLE_CLASS_FILE);
  JavaClass javaClass = parser.parse();

  Set<String> innerClassNames = ClassDumper.listInnerClassNames(javaClass);
  Truth.assertThat(innerClassNames).containsExactly(
      "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreFutureStub",
      "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreMethodDescriptorSupplier",
      "com.google.firestore.v1beta1.FirestoreGrpc$1",
      "com.google.firestore.v1beta1.FirestoreGrpc$MethodHandlers",
      "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreStub",
      "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreBaseDescriptorSupplier",
      "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreBlockingStub",
      "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreImplBase",
      "com.google.firestore.v1beta1.FirestoreGrpc$FirestoreFileDescriptorSupplier"
  );
}
 
Example 2
Source File: Utils.java    From sstable-tools with Apache License 2.0 5 votes vote down vote up
private static File copyResource(String name) throws Exception {
    InputStream is = URLClassLoader.getSystemResourceAsStream(name);
    String tempDir = System.getProperty("java.io.tmpdir");
    File tmp = new File(tempDir + File.separator + name);
    tmp.deleteOnExit();
    ByteStreams.copy(is, new FileOutputStream(tmp));
    return tmp;
}
 
Example 3
Source File: ClassDumperTest.java    From cloud-opensource-java with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
  classFileInputStream = URLClassLoader.getSystemResourceAsStream(EXAMPLE_CLASS_FILE);
}