Code example for URL

Methods: getFile

0
	public void loadingStaticFiles() throws IOException { 
//		URL url  = SocketIOServer.class.getClassLoader().getResource("socket.io.js"); 
		ClassLoader loader = this.getClass().getClassLoader();
		URL url  = loader.getResource("socket.io.js");
		System.out.println(url);
		System.out.println(url.getFile());
 
		InputStream is = loader.getResourceAsStream("socket.io.js");
		String staticRootDir = StaticHandler.getRootDir();
		System.out.println(staticRootDir);
		File file = new File(staticRootDir + "/socket.io.js");
		File parent = file.getParentFile();
		if(parent != null && !parent.exists()) {
			parent.mkdirs();
		} 
		FileCopyUtils.copy(is, new FileOutputStream(staticRootDir + "/socket.io.js"));
	} 
}