avhimkov
7/30/2016 - 10:36 AM

From http://javabeat.net/java-getresourcestream/

package javabeat.net.io;

import java.io.BufferedInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * Java getResourceAsStream() Example
 *
 * @author Krishna
 *
 */
public class GetResourceAsStreamExample {
	public static void main(String[] args) throws IOException,
			FileNotFoundException {
		Class classVar = GetResourceAsStreamExample.class;

		//Loading the file from the current classloaders classpath
		BufferedInputStream fileInputStream = (BufferedInputStream) classVar
				.getClassLoader().getResourceAsStream("resources.properties");
		int i = fileInputStream.read();
		while (i != -1) {
			System.out.println((char) i);
			i = fileInputStream.read();
		}

	}
}