Skip to content

Instantly share code, notes, and snippets.

@khotyn
Created December 1, 2011 09:05
Show Gist options
  • Save khotyn/1415187 to your computer and use it in GitHub Desktop.
Save khotyn/1415187 to your computer and use it in GitHub Desktop.
How to read a file as InputStream from the classpath without using any third party library?
package com.khotyn.test;
import java.io.InputStream;
/**
* Read a file from the classpath without using any third party library.
*
* @author khotyn 2011-12-1 下午5:03:21
*/
public class ReadFromClasspath {
public static void main(String[] args) {
InputStream is = ReadFromClasspath.class.getClassLoader().getResourceAsStream("SomeFile");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment