Here you can find the source of exportResource(Class fromClass, String resourceName, String exportPath)
public static void exportResource(Class fromClass, String resourceName, String exportPath) throws IOException, URISyntaxException
//package com.java2s; //License from project: Open Source License import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URISyntaxException; public class Main { public static void exportResource(Class fromClass, String resourceName, String exportPath) throws IOException, URISyntaxException { InputStream in = null;//from ww w .ja va 2 s .c o m OutputStream out = null; try { in = fromClass.getResourceAsStream(resourceName); if (in == null) { throw new IOException("Cannot get resource \"" + resourceName + "\" from jar."); } int readBytes; byte[] buffer = new byte[4096]; out = new FileOutputStream(exportPath); while ((readBytes = in.read(buffer)) > 0) { out.write(buffer, 0, readBytes); } } finally { if (in != null) in.close(); if (out != null) out.close(); } } }