Here you can find the source of getFile(URI uri)
public static File getFile(URI uri) throws MalformedURLException
//package com.java2s; /******************************************************************************* * Copyright (c) 2006-2007, 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.URI; public class Main { public static File getFile(URI uri) throws MalformedURLException { if (uri == null) return null; String proto = uri.toURL().getProtocol(); if (proto == null) { return new File(uri); } else if ("file".equalsIgnoreCase(proto)) //$NON-NLS-1$ {// w ww. j ava2s . co m String path = uri.toString().replace("file:", ""); return new File(path); } return null; } }