java 判断qq_Java检测QQ是否在线状态
騰訊QQ在線狀態 WEB 服務Endpoint:http://www.webxml.com.cn/webservices/qqOnlineWebService.asmxDisco:http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?discoWSDL:http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl
通過輸入QQ號碼(String)檢測QQ在線狀態。返回數據(String)Y = 在線;N = 離線 ;E = QQ號碼錯誤......
Email 電子郵件地址驗證 WEB 服務Endpoint:http://www.webxml.com.cn/WebServices/ValidateEmailWebService.asmxDisco:http://www.webxml.com.cn/WebServices/ValidateEmailWebService.asmx?discoWSDL:http://www.webxml.com.cn/WebServices/ValidateEmailWebService.asmx?wsdl
Email 電子郵件地址驗證 Web Service,通過查找給定的電子郵件域的郵件服務器和通過向郵件服務器發送數據來判斷電子郵件地址正確與否。此Email地址驗證Web Service請不要用于任何商業目的
Java代碼:
public class ValidatedQQOnline {
public static void main(String[] args) {
while(true) {
System.out.println("請輸入要查詢的QQ號碼、輸入“0”退出");
java.util.Scanner in=new java.util.Scanner(System.in);
String qq = in.next();
if(qq.equals("0")){
break;
}
String result = "";
String charset = "UTF-8";
String callurl = "http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx/qqCheckOnline?qqCode=";
try {
/*
* 通過輸入QQ號碼(String)檢測QQ在線狀態。 返回數據(String)Y = 在線;N = 離線 ;E =
* QQ號碼錯誤
*/
java.net.URL url = new java.net.URL(callurl + qq);
java.net.URLConnection connection = url.openConnection();
connection.connect();
java.io.BufferedReader reader = new java.io.BufferedReader(
new java.io.InputStreamReader(connection
.getInputStream(), charset));
String line;
/*
* 返回的格式 <?xml version="1.0" encoding="utf-8"?>
* xmlns="http://WebXml.com.cn/">E
*/
while ((line = reader.readLine()) != null) {
result += line;
result += "\n";
}
} catch (Exception e) {
e.printStackTrace();
}
int len = result.indexOf("\">");
if (len != -1) {
String qStruts = result.substring(len + 2, len + 3);
if (qStruts.equals("E")) {
System.out.println("QQ號碼錯誤");
} else if (qStruts.equals("Y")) {
System.out.println("在線");
} else if (qStruts.equals("N")) {
System.out.println("離線");
}
} else {
System.out.println("服務器繁忙、請從試!");
}
}
}
}
總結
以上是生活随笔為你收集整理的java 判断qq_Java检测QQ是否在线状态的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: java resources 目录_Ma
- 下一篇: java 雪花特效_java实现图片飘雪
