<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java Interview Questions &#187; URL Class</title>
	<atom:link href="http://www.bestjavainterviewquestions.com/category/url-class/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bestjavainterviewquestions.com</link>
	<description>Java Interview Questions &#124; Core Java Interview Questions &#124; Advanced Java Interview Questions &#124; EJB Interview Questions &#124; J2EE Interview Questions &#124; Hibernate Interview Questions</description>
	<lastBuildDate>Fri, 30 Jul 2010 06:00:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Getting URL contents</title>
		<link>http://www.bestjavainterviewquestions.com/getting-url-contents/</link>
		<comments>http://www.bestjavainterviewquestions.com/getting-url-contents/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 17:43:51 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[URL Class]]></category>
		<category><![CDATA[getting url contents]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=472</guid>
		<description><![CDATA[After you create a URL, you will probably want to fetch contents. The easiest way to do this is by calling the getContent method public final Object getContent() This first method requires that you define a content handler for the content returned by the URL The following example dumps the content of a URL to [...]]]></description>
			<content:encoded><![CDATA[<p>After you create a URL, you will probably want to fetch contents. The easiest way to do this is by calling the getContent method</p>
<p><em>public final Object getContent()</em></p>
<p>This first method requires that you define a content handler for the content returned by the URL</p>
<p>The following example dumps the content of a URL to the System.out.stream by opening an input stream to the URL and reading one byte at a time.</p>
<p><strong><em>Example</em></strong></p>
<p><em>import java.net.*;</em></p>
<p><em>import java.io.*;<br />
class Example1<br />
{<br />
public static void main(String args[]0<br />
{<br />
try {<br />
URL url=new URL(getDocumentBase(),&#8221;main.html&#8221;);<br />
InputStream in=url.openStream();<br />
int b;<br />
while(b=in.read()!=-1)<br />
{<br />
System.out.println((char)b);<br />
} catch(Exception e)<br />
{ System.out.println(&#8220;Exception Due to   &#8211;&gt;&#8221;+e);<br />
e.printStackTrace();<br />
}</em></p>
<p><strong>Getting URL Information</strong></p>
<p>You can retrieve the specific pieces of URL using the following methods</p>
<p><em>public String getProtocol()<br />
public String getHost()<br />
public String getPort()<br />
public String getFile()</em></p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li><a href="http://www.bestjavainterviewquestions.com/ejb-interview-questions-2/" title="EJB Interview questions"><img src="Array" alt="EJB Interview questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/difference-between-sessionsave-and-sessionsaveorupdate-3/" title="Difference between session.save() and session.saveOrUpdate()"><img src="Array" alt="Difference between session.save() and session.saveOrUpdate()" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/mapping-files-in-hibernate/" title="Mapping Files in Hibernate"><img src="Array" alt="Mapping Files in Hibernate" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/explain-executeupdate-method/" title="Explain executeUpdate Method"><img src="Array" alt="Explain executeUpdate Method" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/difference-between-errortag-and-message-tag/" title="Difference between errortag and message tag"><img src="Array" alt="Difference between errortag and message tag" /></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/getting-url-contents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The URL Class</title>
		<link>http://www.bestjavainterviewquestions.com/the-url-class/</link>
		<comments>http://www.bestjavainterviewquestions.com/the-url-class/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 16:33:57 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[URL Class]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=469</guid>
		<description><![CDATA[The URL class enables you to get resource from remote system. After creating a URL object you can retrieve information stored in URL in one of three ways. Use the getCotenet() method in the URL class to fetch the URL&#8217;s content directly Use openConnection method to get URLConnection to the URL Use openStream() method to [...]]]></description>
			<content:encoded><![CDATA[<p>The URL class enables you to get resource from remote system. After creating a URL object you can retrieve information stored in URL in one of three ways.</p>
<p>Use the getCotenet() method in the URL class to fetch the URL&#8217;s content directly</p>
<p>Use openConnection method to get URLConnection to the URL</p>
<p>Use openStream() method to get an InputStream to the URL</p>
<p>The full URL string is the form you are probably most familiar with</p>
<p>URL homepage=new URL(&#8220;http://www.xyz.com&#8221;);</p>
<p>You can create URL by giving the protocol, hostname, filename, and an optional port number</p>
<p>URL homepage=new URL(&#8220;http&#8221;,&#8221;www.xyz.com&#8221;,80);</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li><a href="http://www.bestjavainterviewquestions.com/what-is-log-file/" title="What is LOG FILE"><img src="Array" alt="What is LOG FILE" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/awt-interview-questions/" title="AWT Interview Questions"><img src="Array" alt="AWT Interview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/define-implicit-objects/" title="Define implicit objects"><img src="Array" alt="Define implicit objects" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/what-are-command-line-arguments-in-java/" title="What are Command Line Arguments in Java"><img src="Array" alt="What are Command Line Arguments in Java" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/define-cookies/" title="Define Cookies"><img src="Array" alt="Define Cookies" /></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/the-url-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
