Created
January 3, 2017 17:59
-
-
Save DanyelMorales/45b889110837f0b78884b76a8bbf846e to your computer and use it in GitHub Desktop.
Methods to get Resources or Fixtures in java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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