zoukankan      html  css  js  c++  java
  • 使用java代码打开特定网页

    第一种方法的代码如下所示:

     1 import java.io.File;
     2 
     3 public class Test04 {
     4 
     5     public static void main(String[] args) {
     6         // TODO Auto-generated method stub
     7         try{
     8             Runtime rt = Runtime.getRuntime();
     9             rt.exec("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe");
    10             File file1 = new File("C:/Program Files (x86)/Google/Chrome/Application",
    11                     "chrome www.nwsuaf.edu.cn");
    12             rt.exec(file1.getAbsolutePath());
    13             File file2 = new File("C:/Program Files/Internet Explorer","IEXPLORE www.baidu.com");
    14             rt.exec(file2.getAbsolutePath());
    15             
    16         }
    17         catch(Exception e){}
    18     }
    19 
    20 }

    代码运行后,第9条代码是打开谷歌浏览器,第12条代码时用谷歌浏览器打开特定网址,第14代码是用默认浏览器打开百度。

  • 相关阅读:
    dir 函数
    模块的 __name__
    from..import 语句
    pass
    可变参数
    python 中的一点新知识
    Numpy中的一点小知识
    使用ipython %matplotlib inline
    numpy.random.rand
    Python:numpy中shape和reshape的用法
  • 原文地址:https://www.cnblogs.com/liaoxiaolao/p/9451164.html
Copyright © 2011-2022 走看看