- 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+"抛出异常信息");
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/100720134532.html
来源: http://www.codesnippet.cn/detail/100720134532.html