Java: copy file from jar resources

I was looking for a solution to copy file, build in to jar file to any external location.

Here is the solution, I came to:

significant help for this solution, I got from How To Convert InputStream To File In Java