Java URI to toFile(URI uri)

Here you can find the source of toFile(URI uri)

Description

Creates a File from a URI, the URI can be relative or absolute, this method returns only a file for the Scheme Specific Part.

License

Open Source License

Parameter

Parameter Description
uri the URI to create the file for.

Return

a new file.

Declaration

public static File toFile(URI uri) 

Method Source Code


//package com.java2s;
import java.io.File;

import java.net.URI;

public class Main {
    /**//  ww  w.  ja  va 2s . c o m
     * Creates a File from a URI, the URI can be relative or absolute, this method returns only a file
     * for the Scheme Specific Part.
     *
     * @param uri the URI to create the file for.
     * @return a new file.
     */
    public static File toFile(URI uri) {
        //        if (uri.getScheme() == null) {
        //            try {
        //                uri = new URI("file", uri.getSchemeSpecificPart(), null);
        //            } catch (URISyntaxException e) {
        //                // should never happen
        //                Logger.getLogger(URIUtils.class).fatal(uri, e);
        //            }
        //        }
        return new File((File) null, uri.getSchemeSpecificPart());
    }
}

Related

  1. toExistingFile(URI uri)
  2. toExternalForm(URI u)
  3. toFile(java.net.URI uri)
  4. toFile(String filenameOrFileURI)
  5. toFile(String unixPathOrUri)
  6. toFile(URI uri)
  7. toFileURI(File file)
  8. toFileURI(String path)
  9. tokenizeBase(URI uri)