Here you can find the source of expendResource(String fileName)
public static String expendResource(String fileName) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import java.net.URL; public class Main { public static String expendResource(String fileName) throws Exception { // http://stackoverflow.com/questions/5529532/how-to-get-a-test-resource-file URL url = Thread.currentThread().getContextClassLoader().getResource(fileName); if (url != null) { return new File(url.getPath()).toString(); } else {// w ww. ja va 2 s . c o m throw new IOException(String.format("Resource file [%s] doesn't exist", fileName)); } } }