Java Resource File expendResource(String fileName)

Here you can find the source of expendResource(String fileName)

Description

expend Resource

License

Open Source License

Declaration

public static String expendResource(String fileName) throws Exception 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.io.IOException;
import java.net.URL;

public class Main {
    public static String expendResource(String fileName) throws Exception {
        // http://stackoverflow.com/questions/5529532/how-to-get-a-test-resource-file
        URL url = Thread.currentThread().getContextClassLoader().getResource(fileName);
        if (url != null) {
            return new File(url.getPath()).toString();
        } else {//  w  ww. ja  va  2 s  . c  o m
            throw new IOException(String.format("Resource file [%s] doesn't exist", fileName));
        }
    }
}

Related

  1. copyDecompressed(String resource, File output)
  2. copyResource(String name)
  3. getAllResources(Class clazz, String resource)
  4. getBaseLineFolder(String resourceFile)
  5. getBundlesContainingResource(BundleContext bundleContext, String resourcePattern)
  6. getBytes(Class contextClass, String resourceName)