JAVA如何验证指定QQ用戶状态是否在线
import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; public class Qq{ public static String qUrl = "QQ号码"; private static int state = 1243; public static void main(String[] args) { String urlQ = "http://wpa.qq.com/pa?p=2:"+qUrl+":41"; try { URL url = new URL(urlQ); HttpURLConnection httpUrl = (HttpURLConnection) url.openConnection(); if(state==httpUrl.getContentLength()) System.out.println("QQ用户:["+qUrl+"]状态为在线"); else System.out.println("QQ用户:["+qUrl+"]状态为离线/隐身"); }catch (IOException e) { System.out.println("连接此URL"+urlQ+"抛出异常信息"); } } }