Java tutorial
//package com.java2s; //License from project: Apache License import java.io.FileNotFoundException; import java.io.InputStream; public class Main { private static InputStream loadResourceInputStream(String file) throws FileNotFoundException { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream inputStream = classLoader.getResourceAsStream(file); if (inputStream == null) { throw new FileNotFoundException("File: '" + file + "', not found."); } return inputStream; } }