java url no protocol_httpurlconnection 新人使用遇到错误java.net.MalformedURLException: no protocol...

自己在琢磨中:publicclasshttpurl{  publicstaticvoidmain(String[]args) {       try{URLurl=newURL("www.sina.com.cn&qu...

自己在琢磨中:public class httpurl {  public static void main(String[] args)  {        try { URL url = new URL("www.sina.com.cn");         HttpURLConnection httpurlconnection = (HttpURLConnection)url.openConnection();      //URLConnection   urlconnection =url.openConnection();         httpurlconnection.setConnectTimeout(30000);  // 连接主机超时    httpurlconnection.setReadTimeout(30000);//从主机读取数据超时           System.out.println(httpurlconnection.getContent());  System.out.println(httpurlconnection.getContentType());  System.out.println(httpurlconnection.getDate());  System.out.println(httpurlconnection.getDoInput());  System.out.println(httpurlconnection.getDoOutput());  System.out.println(httpurlconnection.getContentEncoding() );  System.out.println(httpurlconnection.getPermission() );  System.out.println(httpurlconnection.toString()  );          } catch (IOException e) {       e.printStackTrace();        } }}错误出现java.net.MalformedURLException: no protocol: www.sina.com.cn at java.net.URL.(Unknown Source) at java.net.URL.(Unknown Source) at java.net.URL.(Unknown Source) at httpurl.main(httpurl.java:18)这是什么意思啊,网上也查不到

展开

你可能感兴趣的:(java,url,no,protocol)