Here you can find the source of saveResouce(String resourceName, String outputFile)
private static void saveResouce(String resourceName, String outputFile) throws IOException
//package com.java2s; /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { private static void saveResouce(String resourceName, String outputFile) throws IOException { InputStream input = resourceName.getClass().getResourceAsStream(resourceName); OutputStream output;/*w ww .ja va 2 s .c om*/ output = new FileOutputStream(outputFile); writeFile(input, output); output.flush(); output.close(); } private static void writeFile(InputStream input, OutputStream output) throws IOException { byte[] buffer = new byte[1024]; int bytesRead = 0; while ((bytesRead = input.read(buffer)) != -1) { output.write(buffer, 0, bytesRead); } } }