{"id":10211,"date":"2014-06-11T18:10:50","date_gmt":"2014-06-11T15:10:50","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=10211"},"modified":"2014-06-12T08:13:51","modified_gmt":"2014-06-12T05:13:51","slug":"java-net-url-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/","title":{"rendered":"java.net.URL Example"},"content":{"rendered":"<p>In this example, we will show the range of functionality provided by the <a class=\"ext-link\" title=\"java.net.URL\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/net\/URL.html\" target=\"_blank\">java.net.URL<\/a> class. This class represents a Uniform Resource Locator, a pointer to a &#8220;resource&#8221; on the World Wide Web.<\/p>\n<p>An URL is a text string that identifies a resource, tells where to find it, and specifies a method for communicating with it or retrieving it from its source. URLs can have many forms. The most common form has four components; a network <em>host<\/em> or server, the <em>name<\/em> of the resource, its <em>location<\/em> on that host, and a <em>protocol<\/em> by which the host should communicate: <em>protocol:\/\/hostname\/path\/resource-name<\/em>.<\/p>\n<p><em>protocol<\/em> is an identifier such as <em>http<\/em> or <em>ftp<\/em>; <em>hostname<\/em> is usually an Internet host and domain name; and the <em>path<\/em> and <em>resource-name<\/em> components form a unique path that identifies the object on that host.<\/p>\n<p>Let&#8217;s code one of the most common task for which java.net.URL class is used: Read a file using the <em>http<\/em> protocol.<\/p>\n<p>&nbsp;<\/p>\n<h2>1. Example of java.net.URL class<\/h2>\n<p><em><span style=\"text-decoration: underline\">JavaNetURLExample.java<\/span><\/em><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.examples;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.IOException;\r\nimport java.io.InputStreamReader;\r\nimport java.net.MalformedURLException;\r\nimport java.net.URL;\r\n\r\npublic class JavaNetURLExample {\r\n\tpublic static void main(String[] args) {\r\n\t\ttry {\r\n\t\t\t\/\/ Generate absolute URL\r\n\t\t\t\/\/ Base URL = www.gnu.org\r\n\t\t\tURL url1 = new URL(\"http:\/\/www.gnu.org\");\r\n\t\t\tSystem.out.println(\"URL1: \" + url1.toString());\r\n\r\n\t\t\t\/\/ Generate URL for pages with a common base\r\n\t\t\tURL url2 = new URL(url1, \"licenses\/gpl.txt\");\r\n\t\t\tSystem.out.println(\"URL2: \" + url2.toString());\r\n\r\n\t\t\t\/\/ Generate URLs from different pieces of data\r\n\t\t\tURL url3 = new URL(\"http\", \"www.gnu.org\", \"\/licenses\/gpl.txt\");\r\n\t\t\tSystem.out.println(\"URL3: \" + url3.toString());\t\r\n\t\t\t\r\n\t\t\tURL url4 = new URL(\"http\", \"www.gnu.org\", 80, \"\/licenses\/gpl.txt\");\r\n\t\t\tSystem.out.println(\"URL4: \" + url4.toString() + \"\\n\");\r\n\r\n\t\t\t\/\/ Open URL stream as an input stream and print contents to command line\r\n\t\t\ttry (BufferedReader in = new BufferedReader(new InputStreamReader(url4.openStream()))) {\r\n\t\t\t\tString inputLine;\r\n\r\n\t\t\t\t\/\/ Read the \"gpl.txt\" text file from its URL representation\r\n\t\t\t\tSystem.out.println(\"\/***** File content (URL4) *****\/n\");\r\n\t\t\t\twhile((inputLine = in.readLine()) != null) {\r\n\t\t\t\t\tSystem.out.println(inputLine);\r\n\t\t\t\t}\r\n\t\t\t} catch (IOException ioe) {\r\n\t\t\t\tioe.printStackTrace(System.err);\r\n\t\t\t}\r\n\t\t} catch (MalformedURLException mue) {\r\n\t\t\tmue.printStackTrace(System.err);\r\n\t\t}\r\n\t}\r\n}\r\n<\/pre>\n<p>Let\u2019s explain the methods used in the above example.<\/p>\n<ul>\n<li><code><a title=\"URL(java.lang.String)\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/net\/URL.html#URL(java.lang.String)\" target=\"_blank\">URL(String spec)<\/a><\/code> &#8211; Creates a URL object from the String representation. This constructor is equivalent to a call to the two-argument constructor with a <em>null<\/em> first argument.<\/li>\n<li><code><a title=\"URL(URL context, String spec)\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/net\/URL.html#URL(java.net.URL,%20java.lang.String)\" target=\"_blank\">URL(URL context, String spec)<\/a><\/code> &#8211; Creates a URL by parsing the given <em>spec<\/em> within a specified <em>context<\/em>. The new URL is created from the given <em>context<\/em> URL and the <em>spec<\/em> argument as described in <code><a title=\"RFC2396\" href=\"http:\/\/www.faqs.org\/rfcs\/rfc2396.html\" target=\"_blank\">RFC2396 \"Uniform Resource Identifiers\" Generic Syntax<\/a><\/code>.<\/li>\n<li><code><a title=\"URL(String protocol, String host, String file)\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/net\/URL.html#URL(java.lang.String,%20java.lang.String,%20java.lang.String)\" target=\"_blank\">URL(String protocol, String host, String file)<\/a><\/code> &#8211; Creates a URL from the specified <em>protocol<\/em> name, <em>host<\/em> name, and <em>file<\/em> name. The default port for the specified protocol is used.<\/li>\n<li><code><a title=\"openStream()\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/net\/URL.html#openStream()\" target=\"_blank\">openStream()<\/a><\/code> &#8211; Opens a connection to this URL and returns an <code><a title=\"InputStream\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/io\/InputStream.html\" target=\"_blank\">InputStream<\/a><\/code> for reading from that connection.<\/li>\n<li><code><a title=\"(String protocol, String host, int port, String file)\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/net\/URL.html#URL(java.lang.String,%20java.lang.String,%20int,%20java.lang.String)\" target=\"_blank\">(String protocol, String host, int port, String file)<\/a><\/code> &#8211; Creates a URL object from the specified <em>protocol<\/em>, <em>host<\/em>, <em>port<\/em> number, and <em>file<\/em>. <em>host<\/em> can be expressed as a host name or a literal IP address. Specifying a <em>port<\/em> number of -1 indicates that the URL should use the default port for the protocol.<\/li>\n<\/ul>\n<p>If we run the above code, we will get the following results:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:bash\">URL1: http:\/\/www.gnu.org\r\nURL2: http:\/\/www.gnu.org\/licenses\/gpl.txt\r\nURL3: http:\/\/www.gnu.org\/licenses\/gpl.txt\r\nURL4: http:\/\/www.gnu.org:80\/licenses\/gpl.txt\r\n\r\n\/***** File content (URL4) *****\/\r\n\r\n                    GNU GENERAL PUBLIC LICENSE\r\n                       Version 3, 29 June 2007\r\n\r\n Copyright (C) 2007 Free Software Foundation, Inc. \r\n Everyone is permitted to copy and distribute verbatim copies\r\n of this license document, but changing it is not allowed.\r\n\r\n                            Preamble\r\n\r\n  The GNU General Public License is a free, copyleft license for\r\nsoftware and other kinds of works.\r\n\r\n  The licenses for most software and other practical works are designed\r\nto take away your freedom to share and change the works.  By contrast,\r\nthe GNU General Public License is intended to guarantee your freedom to\r\nshare and change all versions of a program--to make sure it remains free\r\nsoftware for all its users.  We, the Free Software Foundation, use the\r\nGNU General Public License for most of our software; it applies also to\r\nany other work released this way by its authors.  You can apply it to\r\nyour programs, too.\r\n<\/pre>\n<h2>2. Some more methods of the java.net.URL class<\/h2>\n<p><em><span style=\"text-decoration: underline\">JavaNetURLMoreMethodsExample.java<\/span><\/em><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.examples;\r\n\r\nimport java.io.IOException;\r\nimport java.net.URL;\r\n\r\npublic class JavaNetURLMoreMethodsExample {\r\n\tpublic static void main(String[] args) {\r\n\t\ttry {\r\n\t\t\t\/\/ Creates a URL object from the String representation.\r\n\t\t\tURL url = new URL(\"http:\/\/www.gnu.org\/licenses\/gpl.txt\");\r\n\r\n\t\t\t\/\/ Gets the authority part of this URL.\r\n\t\t\tSystem.out.println(\"URL Authority: \" + url.getAuthority());\r\n\r\n\t\t\t\/\/ Gets the default port number of the protocol associated with this URL.\r\n\t\t\tSystem.out.println(\"URL Default Port: \" + url.getDefaultPort());\r\n\r\n\t\t\t\/\/ Gets the file name of this URL.\r\n\t\t\tSystem.out.println(\"URL File Name: \" + url.getFile());\r\n\r\n\t\t\t\/\/ Gets the host name of this URL, if applicable.\r\n\t\t\tSystem.out.println(\"URL Host Name: \" + url.getHost());\r\n\r\n\t\t\t\/\/ Gets the path part of this URL.\r\n\t\t\tSystem.out.println(\"URL Path: \" + url.getPath());\r\n\r\n\t\t\t\/\/ Gets the protocol name of this URL.\r\n\t\t\tSystem.out.println(\"URL Protocal Name: \" + url.getProtocol());\r\n\t\t} catch (IOException ioe) {\r\n\t\t\tioe.printStackTrace(System.err);\r\n\t\t}\r\n\t}\r\n}\r\n<\/pre>\n<p>Let\u2019s explain the methods used in the above example.<\/p>\n<ul>\n<li><code><a title=\"getAuthority()\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/net\/URL.html#getAuthority()\" target=\"_blank\">getAuthority()<\/a><\/code> &#8211; Gets the authority part of this URL.<\/li>\n<li><code><a title=\"getDefaultPort()\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/net\/URL.html#getDefaultPort()\" target=\"_blank\">getDefaultPort()<\/a><\/code> &#8211; Gets the default port number of the protocol associated with this URL. If the URL scheme or the URLStreamHandler for the URL do not define a default port number, then -1 is returned.<\/li>\n<li><code><a title=\"getFile()\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/net\/URL.html#getFile()\" target=\"_blank\">getFile()<\/a><\/code> &#8211; Gets the file name of this URL, or an empty string if one does not exist.<\/li>\n<li><code><a title=\"getHost()\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/net\/URL.html#getHost()\" target=\"_blank\">getHost()<\/a><\/code> &#8211; Gets the host name of this URL, if applicable. The format of the host conforms to <a title=\"RFC2732\" href=\"http:\/\/www.faqs.org\/rfcs\/rfc2732.html\" target=\"_blank\">RFC2732<\/a>, i.e. for a literal IPv6 address, this method will return the IPv6 address enclosed in square brackets (&#8216;[&#8216; and &#8216;]&#8217;).<\/li>\n<li><code><a title=\"getPath()\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/net\/URL.html#getPath()\" target=\"_blank\">getPath()<\/a><\/code> &#8211; Gets the path part of this URL, or an empty string if one does not exist.<\/li>\n<li><code><a title=\"getProtocol()\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/net\/URL.html#getProtocol()\" target=\"_blank\">getProtocol()<\/a><\/code> &#8211; Gets the protocol name of this URL.<\/li>\n<\/ul>\n<p>If we run the above code, we will get the following results:<\/p>\n<pre class=\"brush:bash\">URL Authority: www.gnu.org\r\nURL Default Port: 80\r\nURL File Name: \/licenses\/gpl.txt\r\nURL Host Name: www.gnu.org\r\nURL Path: \/licenses\/gpl.txt\r\nURL Protocal Name: http\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h2>3. Download the source code<\/h2>\n<p>You can download the source code of this example from here: <a title=\"JavaNetURLClass.zip\" href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/06\/JavaNetURLClass.zip\">JavaNetURLClass.zip<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this example, we will show the range of functionality provided by the java.net.URL class. This class represents a Uniform Resource Locator, a pointer to a &#8220;resource&#8221; on the World Wide Web. An URL is a text string that identifies a resource, tells where to find it, and specifies a method for communicating with it &hellip;<\/p>\n","protected":false},"author":18,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[],"class_list":["post-10211","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-url"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>java.net.URL Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this example, we will show the range of functionality provided by the java.net.URL class. This class represents a Uniform Resource Locator, a pointer\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"java.net.URL Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this example, we will show the range of functionality provided by the java.net.URL class. This class represents a Uniform Resource Locator, a pointer\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2014-06-11T15:10:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-06-12T05:13:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Armando Flores\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Armando Flores\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/\"},\"author\":{\"name\":\"Armando Flores\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/edd8d967774c2c27aac159acda5ca9fe\"},\"headline\":\"java.net.URL Example\",\"datePublished\":\"2014-06-11T15:10:50+00:00\",\"dateModified\":\"2014-06-12T05:13:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/\"},\"wordCount\":507,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"articleSection\":[\"URL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/\",\"name\":\"java.net.URL Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2014-06-11T15:10:50+00:00\",\"dateModified\":\"2014-06-12T05:13:51+00:00\",\"description\":\"In this example, we will show the range of functionality provided by the java.net.URL class. This class represents a Uniform Resource Locator, a pointer\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"net\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/net\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"URL\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/net\/url\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"java.net.URL Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/edd8d967774c2c27aac159acda5ca9fe\",\"name\":\"Armando Flores\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/05\/Armando-Flores-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/05\/Armando-Flores-96x96.jpg\",\"caption\":\"Armando Flores\"},\"description\":\"Armando graduated from from Electronics Engineer in the The Public University Of Puebla (BUAP). He also has a Masters degree in Computer Sciences from CINVESTAV. He has been using the Java language for Web Development for over a decade. He has been involved in a large number of projects focused on \\\"ad-hoc\\\" Web Application based on Java EE and Spring Framework.\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\/\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/armando-flores\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"java.net.URL Example - Java Code Geeks","description":"In this example, we will show the range of functionality provided by the java.net.URL class. This class represents a Uniform Resource Locator, a pointer","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/","og_locale":"en_US","og_type":"article","og_title":"java.net.URL Example - Java Code Geeks","og_description":"In this example, we will show the range of functionality provided by the java.net.URL class. This class represents a Uniform Resource Locator, a pointer","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2014-06-11T15:10:50+00:00","article_modified_time":"2014-06-12T05:13:51+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Armando Flores","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Armando Flores","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/"},"author":{"name":"Armando Flores","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/edd8d967774c2c27aac159acda5ca9fe"},"headline":"java.net.URL Example","datePublished":"2014-06-11T15:10:50+00:00","dateModified":"2014-06-12T05:13:51+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/"},"wordCount":507,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","articleSection":["URL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/","name":"java.net.URL Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2014-06-11T15:10:50+00:00","dateModified":"2014-06-12T05:13:51+00:00","description":"In this example, we will show the range of functionality provided by the java.net.URL class. This class represents a Uniform Resource Locator, a pointer","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/net\/url\/java-net-url-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"net","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/net\/"},{"@type":"ListItem","position":5,"name":"URL","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/net\/url\/"},{"@type":"ListItem","position":6,"name":"java.net.URL Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/edd8d967774c2c27aac159acda5ca9fe","name":"Armando Flores","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/05\/Armando-Flores-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/05\/Armando-Flores-96x96.jpg","caption":"Armando Flores"},"description":"Armando graduated from from Electronics Engineer in the The Public University Of Puebla (BUAP). He also has a Masters degree in Computer Sciences from CINVESTAV. He has been using the Java language for Web Development for over a decade. He has been involved in a large number of projects focused on \"ad-hoc\" Web Application based on Java EE and Spring Framework.","sameAs":["http:\/\/www.javacodegeeks.com\/"],"url":"https:\/\/examples.javacodegeeks.com\/author\/armando-flores\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/10211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=10211"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/10211\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=10211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=10211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=10211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}