Java Resource Path Get getResource(String path)

Here you can find the source of getResource(String path)

Description

get Resource

License

Apache License

Declaration

public static File getResource(String path) 

Method Source Code


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

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;

public class Main {
    public static File getResource(String path) {
        // TODO: not nice to have the hard coded bundle name
        URL bundleurl = Platform.getBundle("de.schenk.jrtrace.service.test").getEntry(path);

        try {/*from  w w w . ja  v  a2s  .  c o  m*/
            URL fileURL = FileLocator.toFileURL(bundleurl);
            return new File(fileURL.toURI());
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}

Related

  1. getPluginResource(Bundle bundle, String resourcePath)
  2. getRelativeResource(Class clazz, String relativePath)
  3. getResource(Class cl, String path)
  4. getResource(final Class baseClass, final String path)
  5. getResource(final String path)
  6. getResource(String path)
  7. getResource(String relativePath)
  8. getResource(String resourcePath)
  9. getResourceAsFile(Object relativeTo, String relativePath)