Here you can find the source of normalizeToURL(String surl)
public static URL normalizeToURL(String surl) throws MalformedURLException
//package com.java2s; /**/*from w w w . j ava 2s. c o m*/ * Copyright (c) 2006-2010, Cloudsmith Inc. * The code, documentation and other materials contained herein have been * licensed under the Eclipse Public License - v 1.0 by the copyright holder * listed above, as the Initial Contributor under such license. The text of * such license is available at www.eclipse.org. */ import java.io.File; import java.net.MalformedURLException; import java.net.URL; public class Main { public static URL normalizeToURL(String surl) throws MalformedURLException { if (surl == null) return null; try { return new URL(surl); } catch (MalformedURLException e) { // Do a space check. // if (surl.indexOf(' ') > 0) { try { return new URL(surl.replaceAll("\\s", "%20")); //$NON-NLS-1$ //$NON-NLS-2$ } catch (MalformedURLException me1) { } } try { return new File(surl).toURI().toURL(); } catch (MalformedURLException me2) { // Throw the original exception // throw e; } } } }