Java examples for Internationalization:Resource File
get File from resource
import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; import java.net.URISyntaxException; import java.net.URL; public class Main{ public static void main(String[] argv) throws Exception{ String file = "java2s.com"; System.out.println(getFile(file)); }/*w w w.j av a 2s .c o m*/ private static File getFile(String file) { return new File(new File(getBaseFolder(), "buffer/"), file); } private static File getBaseFolder() { return getResourceAsFile("/"); } private static File getResourceAsFile(String file) { URL url = Main.class .getResource(file); try { return new File(url.toURI()); } catch (URISyntaxException e) { return new File(url.getPath()); } } }