Java File Class toURI() Method with Examples Last Updated : 02 Feb, 2022 Comments Improve Suggest changes Like Article Like Report The toURI() method returns the URI that corresponds to the supplied URL. This method works similarly to the new URI (this.toString()). This abstract pathname is represented by a file: URI. Syntax: public URI toURI() Returns: It returns an absolute hierarchical URI with the scheme "file," a path that represents this abstract pathname, and undefined authority, query, and fragment components. Exception: SecurityException: If you can't get to a needed system property value Example: Java // Java Program to demonstrate the working // of toURI() method of File Class import java.io.File; import java.net.URI; public class GFG { public static void main (String[] args) { File f = new File("C:\\GEEKSFORGEEKS\\hello.txt"); try { URI uri = f.toURI(); System.out.println("uri is :- " + uri); } catch (SecurityException e) { e.printStackTrace(); } } } Output: Comment More infoAdvertise with us Next Article Java File Class toURI() Method with Examples S sanketnagare Follow Improve Article Tags : Java Java-Functions Java-File Class Practice Tags : Java Similar Reads Class toGenericString() method in Java with Examples The toGenericString() method of java.lang.Class class is used to convert the instance of this Class to a string representation along with the information about the modifiers and type parameters. This method returns the formed string representation. Syntax: public String toGenericString() Parameter: 2 min read URL toURI() method in Java with Examples The getURI() function of URL class converts the URL object to a URI object. Any URL which compiles with RFC 2396 can be converted to URI. URLs which are not in the specified format will generate an error if converted to URI format. Function Signature public URI toURI() Syntax url.toURI() Parameter: 2 min read Path toUri() method in Java with Examples The toUri() method of java.nio.file.Path interface used to return a URI to represent this path. This method converts this path into an absolute URI with a scheme equal to the URI scheme that identifies the provider. The exact form of the scheme-specific part is highly provider dependent. In the scen 2 min read Class forName() method in Java with Examples The forName() method of java.lang.Class class is used to get the instance of this Class with the specified class name. This class name is specified as the string parameter.Syntax: public static Class<T> forName(String className) throws ClassNotFoundException Parameter: This method accepts the 1 min read Bidi toString() method in Java with Examples The toString() method of java.text.Bidi class is used to display this Bidi instance in string representation. Syntax: public String toString() Parameter: This method accepts nothing as parameter. Return Value: This method display internal state of bidi in string format. Below are the examples to ill 2 min read Like