Here you can find the source of resolve(final URL url)
Parameter | Description |
---|---|
url | The URL to resolve (can be workspace-relative) |
public static File resolve(final URL url)
//package com.java2s; /******************************************************************************* * Copyright (c) 2009, 2015 Fabian Steeg. 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 * <p/>//from w w w . ja va 2 s . com * Contributors: Fabian Steeg - initial API and implementation; see bug 277380 *******************************************************************************/ import java.io.File; import java.net.URISyntaxException; import java.net.URL; public class Main { /** * @param url * The URL to resolve (can be workspace-relative) * @return The file corresponding to the given URL */ public static File resolve(final URL url) { File resultFile = null; URL resolved = url; /* * If we don't check the protocol here, the FileLocator throws a * NullPointerException if the URL is a normal file URL. */ if (!url.getProtocol().equals("file")) { //$NON-NLS-1$ throw new IllegalArgumentException("Unsupported protocol: " //$NON-NLS-1$ + url.getProtocol()); } try { resultFile = new File(resolved.toURI()); } catch (URISyntaxException e) { e.printStackTrace(); } return resultFile; } }