用java的http的连接类联一下不就知道了,你也可以自己用socket连接www.sohu.com的80端口也行阿。
解决方案 »
- 对象实例化过程
- java中有没有 将JTextArea 内的文本全复制到系统剪贴板的方法?我查遍API,就只有将选中文本复制的copy方法
- 怎么知道firefox是否支持script(javascript,vbscript)
- struts上传文件时,如何限制文件格式?
- java菜单编程
- 大侠们回忆下基础。顺便帮我解释下呵呵。
- (急急急)怎么在installAnywhere中加入自己的jre?
- 请看看我的毕业设计(产业信息资源库)的需求分析中的功能分析。
- 请问有没有 for access 的 jdbc driver?
- 请问高手们,如何用JAVA实现ftp协议?
- 有谁知道policytool是干什么的,能解决applet访问数据库的问题吗??100分,跟贴有分!
- netscape.javascript.JSObject在IE中不定期出错.在线等..高手请进..
import java.net.URL;public class TestUrl
{ public static void main(String args[])
{
Object obj = null;
try
{
URL url = new URL("http://www.sina.com.cn");
System.out.println("the url is right");
return;
}
catch(Exception _ex)
{
System.out.println("the url is error");
}
} public TestUrl()
{
}
}
import java.io.*;public class URLC {
public static void main(String args[]) {
String sURL = "http://www.sohu.com/index.jsp";
URL l_url = null;
URLConnection l_connection = null;
InputStream l_urlStream = null;
int value;
String sTotalString = "";
try {
l_url = new URL(sURL);
} catch(MalformedURLException e) {
System.out.println(e.toString());
}
try {
l_connection = l_url.openConnection();
l_connection.connect();
l_urlStream = l_connection.getInputStream(); while ((value = l_urlStream.read()) != -1) { sTotalString += (char)value;
}
} catch(IOException e) {
System.out.println(e.toString());
}
System.out.println(sTotalString);
}
}如果sTotalString != ""就能提供服务。