URL toExternalForm() method in Java with Examples Last Updated : 31 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The toExternalForm() function is a part of URL class. The function toExternalForm() returns the string representation of a specified URL. The string is created by calling the toExternalForm() function of the stream protocol handler for this object. Function Signature: public String toExternalForm() Syntax: url.toExternalForm() Parameter: This function does not require any parameter Return Type: The function returns String Type Below programs illustrates the use of toExternalForm() function: Example 1: Given a URL we will to the string representation of the URL Java // Java program to show the // use of the function toExternalForm() import java.net.*; class Solution { public static void main(String args[]) { // url object URL url = null; try { // create a URL url = new URL("https:// www.geeksforgeeks.org"); // get the ExternalForm String _ExternalForm = url.toExternalForm(); // display the URL System.out.println("URL = " + url); // display the ExternalForm System.out.println(" String representation= " + _ExternalForm); } // if any error occurs catch (Exception e) { // display the error System.out.println(e); } } } Output: URL = https:// www.geeksforgeeks.org String representation= https:// www.geeksforgeeks.org Example 2: Java // Java program to show the // use of the function toExternalForm() import java.net.*; class Solution { public static void main(String args[]) { // url object URL url = null; try { // create a URL url= new URL("https:// www.geeksforgeeks.org#Arnab_Kundu"); // get the ExternalForm String _ExternalForm = url.toExternalForm(); // display the URL System.out.println("URL = " + url); // display the ExternalForm System.out.println(" String representation= " + _ExternalForm); } // if any error occurs catch (Exception e) { // display the error System.out.println(e); } } } Output: URL = https:// www.geeksforgeeks.org#Arnab_Kundu String representation= https:// www.geeksforgeeks.org#Arnab_Kundu Comment More infoAdvertise with us Next Article URL toExternalForm() method in Java with Examples andrew1234 Follow Improve Article Tags : Java Java-Functions Java-net-package Java-URL Practice Tags : Java Similar Reads 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 UUID toString() Method in Java with Examples The toString() method of UUID class in Java is generally used to get the string representation of this UUID. Syntax: public String toString() Parameters: This method does not take any parameter. Return Value: This method returns a String value which is the string representation of this UUID. Below p 1 min read URL sameFile() method in Java with Examples The sameFile() function of Java.net.URL class is used to compare two URLs excluding the fragment part. This method returns true if both the URL are same excluding the fragment part else returns false. Function Signature public boolean sameFile(URL u) Syntax url1.sameFile(url2); Parameter: This metho 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 Byte toString() method in Java with examples The toString() method of Byte class is a built in method in Java which is used to return a String value. public String toString() Syntax: ByteObject.toString() Return Value: It returns a String object, the value of which is equal to the value of the ByteObject. Below is the implementation of toStrin 2 min read Like