Java Resource File copyResource(String name)

Here you can find the source of copyResource(String name)

Description

copy Resource

License

Apache License

Declaration

private static File copyResource(String name) throws Exception 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import com.google.common.io.ByteStreams;
import java.io.File;

import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URLClassLoader;

public class Main {
    private static File copyResource(String name) throws Exception {
        InputStream is = URLClassLoader.getSystemResourceAsStream(name);
        String tempDir = System.getProperty("java.io.tmpdir");
        File tmp = new File(tempDir + File.separator + name);
        tmp.deleteOnExit();/*www .ja  v  a2  s. c  o m*/
        ByteStreams.copy(is, new FileOutputStream(tmp));
        return tmp;
    }
}

Related

  1. copyDecompressed(String resource, File output)
  2. expendResource(String fileName)
  3. getAllResources(Class clazz, String resource)
  4. getBaseLineFolder(String resourceFile)
  5. getBundlesContainingResource(BundleContext bundleContext, String resourcePattern)