I was trying this piece of code.Why would this give the java.net.UnknownHostException: www.oracle.com .The URl is pretty correct.Isn't it?
import java.net.*;
import java.io.*;
public class Urlread {
public static void main(String[] args) throws Exception {
URL oracle = new URL("http://www.oracle.com/");
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
There is nothing wrong with your code. You just need to check the internet connection on the machine from where you are trying to run this code. I am able to successfully run the shared code and here is the snippet of output:
var _U = "undefined"; var g_HttpRelativeWebRoot = "/ocom/"; var SSContributor = false; var SSForceContributor = false; var SSHideContributorUI = false; var ssUrlPrefix = "/us/"; var ssUrlType = "2"; var g_navNode_Path = new Array(); g_navNode_Path[0] = '8'; var g_ssSourceNodeId = "8"; var g_ssSourceSiteId = "ocomen";
var g_strLanguageId = "en";
<fragmentinstance id="fragment3" fragmentid="ocomheader" library="server:OCOMHEADER"> </fragmentinstance> <fragmentinstance id="fragment4" fragmentid="ocomfooter" library="server:OCOMFOOTER"> </fragmentinstance> <fragmentinstance id="fragment5" fragmentid="sitecatalyst-ocom-standard"
library="server:SITECATALYST-OCOM-STANDARD">
</fragmentinstance> <fragmentinstance id="fragment6" fragmentid="ocomhp-commonassets" library="server:OCOMHP-COMMONASSETS"> </fragmentinstance> <fragmentinstance id="fragment7" fragmentid="ATGChat" library="server:ATG_CHAT"> </fragmentinstance> <fragmentinstance id="fragment8" fragmentid="UniversalSiteStudioManager"
library="server:UNIVERSAL_SITE_STUDIO_MANAGER">
</ssinfo> </script>
Oracle | Hardware and Software, Engineered to Work Together
<!--SS_END_SNIPPET(fragment1,head_tags)--> <!--
SS_BEGIN_SNIPPET(fragment6,ocomhp-commonassets)--> .menu-otn {display:none;}
var atg_fName = ""; var atg_lName = ""; var atg_eMail = ""; var atg_company = ""; //If User is logged in if (USER.guid) { //Read user properties from cookie object USER atg_fName = USER.firstname; atg_lName = USER.lastname; atg_eMail = USER.username;
//Get cookie value ORA_WWW_PERSONALIZE and tokenize it to get value
for cn (company name) var personalizeCookie = (function(){ var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i set to true } if(personalizeCookie != null && trustchk) { var cPair = ""; var cName = "" var cValue = ""; var all_values = personalizeCookie.split( '~' ); for (var i = 0; i < all_values.length; i++ ) { cPair = all_values[i].split( ':' ); cName = cPair[0].replace(/^\\s+|\\s+$/g, ''); if (cName == "cn") { cValue = unescape(cPair[1].replace(/^\\s+|\\s+$/g, '')); break; } } if (cValue.length != 0) { atg_company = cValue; } } }); }
var atg_country = "US";
Oracle
Select Country/Region
Select Country/Region Communities I am a... I want to... Welcome Account Sign Out Sign In/Register for Account Help
Products and Services
Solutions
Downloads
Store
Support
Training
Partners
About
Oracle Technology Network
Oracle Database 12 c
Plug Into the Cloud
Oracle OpenWorld
Register now
Oracle Cloud Application Foundation
View the Webcast
Big Data
Making the big data transformation
Introducing Oracle Database 12 c
Get a firsthand look at the only database designed for the cloud. Join us at Oracle Technology Day.
Find an Event Near YouPlug Into the Cloud
Mark Hurd and Andy Mendelsohn join Tom Kyte to show how Oracle helps you tap into the benefits of the cloud.
Watch the WebcastRegister for Oracle OpenWorld 2013
Meet new peers, make the right connections,
Register now
build your community.Make the Future Java at JavaOne
Go to registrationAnnouncing Oracle Cloud Application Foundation
Deliver next-generation applications with Oracle WebLogic Server.
Register for the July 31st WebcastExtreme Performance with the Highest Availability</nobr></h3>
Learn more about the Oracle SuperCluster T5-8</p> Find out more</a></div> </div> </div>-->
Transform Your Business With Big Data
IT strategies to capture, store, and manage growing volumes of data.
Learn more A Big Data ConversationJoin Oracle Big Data Strategist Paul Sonderegger and MIT Principal Research Scientist Andrew McAfee as they discuss big data.
Register for the July 30th WebcastTransform Your Business With Oracle Cloud
Plan EffectivelySupport Customers
- Enterprise Resource Planning
- Planning and Budgeting
- Financial Reporting
Empower People
- Customer Service and Support
Get Social
- Human Capital Management
- Talent Management
- Talent Management for SMB
Social Network Social Marketing Social Engagement and Monitoring
如果您在Android上运行,建议您检查INTERNET权限,但是由于情况并非如此,因此您应该检查机器的Internet访问,防火墙,代理,DNS等,当然还要检查您的应用程序的Internet连接。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.