Here you can find the source of getResource(String relativePath)
public static File getResource(String relativePath) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2016 IBM Corporation.//from w ww .j a v a2 s . c o m * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ import java.io.File; import java.io.IOException; import java.net.URI; 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 final String PLUGIN_ID = "org.eclipse.wst.jsdt.js.node.common.tests"; public static File getResource(String relativePath) throws IOException { if (Platform.isRunning()) { URL fileURL = Platform.getBundle(PLUGIN_ID).getEntry( relativePath); File file = null; try { if (FileLocator.resolve(fileURL).toString().indexOf(" ") > -1) { URL location = FileLocator.resolve(fileURL); URI resolvedUri = new URI(location.getProtocol(), location.getPath(), null); file = new File(resolvedUri); } else { file = new File(FileLocator.resolve(fileURL).toURI()); } } catch (URISyntaxException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return file; } throw new IllegalStateException("Platform not running"); //$NON-NLS-1$ } }