Skip to content

Instantly share code, notes, and snippets.

@andreyserdjuk
Last active September 4, 2015 19:51
Show Gist options
  • Save andreyserdjuk/7b82847d2c01757c185d to your computer and use it in GitHub Desktop.
Save andreyserdjuk/7b82847d2c01757c185d to your computer and use it in GitHub Desktop.
read file content from jar
import org.apache.commons.io.IOUtils;
try {
// approach 1
String extractProducts = IOUtils.toString(getClass().getResourceAsStream("/extractProducts.js"));
// approach 2
byte[] bytes = Files.readAllBytes(Paths.get(getClass().getResource("/extractProducts.js").getPath()));
String js_extractProducts = new String(bytes);
} catch (IOException e) {
logger.error("cannot find extractProducts.js, exiting...");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment