Here you can find the source of toFile(URI uri)
null
if the given URI does not represent a local file.
Parameter | Description |
---|---|
uri | The URI to return the file for |
null
public static File toFile(URI uri)
//package com.java2s; // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt import java.io.File; import java.net.URI; public class Main { public static final String SCHEME_FILE = "file"; /**// w w w .j ava 2 s . c o m * Returns the URI as a local file, or <code>null</code> if the given URI does not represent a local file. * * @param uri The URI to return the file for * @return The local file corresponding to the given URI, or <code>null</code> */ public static File toFile(URI uri) { try { if (!SCHEME_FILE.equalsIgnoreCase(uri.getScheme())) { return null; } // assume all illegal characters have been properly encoded, so use URI class to unencode return new File(uri); } catch (IllegalArgumentException e) { // File constructor does not support non-hierarchical URI String path = uri.getPath(); // path is null for non-hierarchical URI such as file:c:/tmp if (path == null) { path = uri.getSchemeSpecificPart(); } return new File(path); } } }