public static void copyResource ( String resource , File destination ) throws IOException { InputStream is = null ; FileOutputStream fos = null ; try { is = FileUtils . class . getResourceAsStream ( "/" + resource ) ; fos = new FileOutputStream ( destination ) ; final byte [ ] buffer = new byte [ 10 * 1024 ] ; int len ; while ( ( len = is . read ( buffer ) ) > 0 ) { fos . write ( buffer , 0 , len ) ; } } finally { close ( is ) ; close ( fos ) ; } }
Copy a classpath resource to a destination file .