Skip to content

Instantly share code, notes, and snippets.

@DanyelMorales
Created January 3, 2017 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanyelMorales/45b889110837f0b78884b76a8bbf846e to your computer and use it in GitHub Desktop.
Save DanyelMorales/45b889110837f0b78884b76a8bbf846e to your computer and use it in GitHub Desktop.
Methods to get Resources or Fixtures in java
/**
* Resource resolution
*/
private String getFixture(String name) throws IOException {
String result = "";
ClassLoader classLoader = getClass().getClassLoader();
try {
result = IOUtils.toString(classLoader.getResourceAsStream(name));
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
public static String resourceFilePath(final String resourceClassPathLocation) {
try {
return new File(Resources.getResource(resourceClassPathLocation)
.toURI()).getAbsolutePath();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment