Skip to content

Instantly share code, notes, and snippets.

@seveniu
Last active July 18, 2016 14:20
Show Gist options
  • Save seveniu/8b2189e87d5ea53c406917d1342aa065 to your computer and use it in GitHub Desktop.
Save seveniu/8b2189e87d5ea53c406917d1342aa065 to your computer and use it in GitHub Desktop.
java 中获取 resource ,适用于 jar 内资源
InputStream in = getClass().getClassLoader().getResourceAsStream("ParseResult.groovy");
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder builder = new StringBuilder();
String aux = "";
while ((aux = reader.readLine()) != null) {
builder.append(aux);
}
String text = builder.toString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment