java实现自动打开网页 自动提交数据

来源:互联网 发布:淘宝怎么提交订单 编辑:程序博客网 时间:2024/05/14 08:20
 

package common;

/**
 * @author zhangfj @email yjia2009@yahoo.cn
 * @date 2012-2-16 涓嬪崍07:21:55
 */
import java.io.*;
import java.net.URL;
import java.net.URLConnection;


public class getUrlContent {

 /**
  * @param args
  */
 public static void main(String[] args) throws IOException{
  // TODO Auto-generated method stub
  test();
 }
 public static void test()throws IOException{
//  URL url=new URL("http://localhost:7001/login.jsp");
//  Object obj = url.getContent();
//  InputStream in=(InputStream) obj;
//        byte[]tt=new byte[in.available()];
//        int z;
//        while((z=in.read(tt, 0, tt.length))!=-1){
//         System.out.println(new String(tt,"utf-8"));
//        }
       // System.out.println(obj.getClass().getName());
  
 // String strURL = "http://localhost:7001/Login.do?usercode=system\"&\"password=" ;
  String strURL = "http://ptlogin2.qq.com/login?u=859480017@qq.com\"&\"p=\131211221" ;
  Process p = Runtime.getRuntime().exec("cmd /c start " + strURL );
  try {
   p .waitFor();
  } catch (InterruptedException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 }
}