rt

解决方案 »

  1.   

    package test;import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.net.URL;public class Net {

    /**
     * @param args
     */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    try{
    URL url=new URL("file://localhost:/d:/2.html");
    url.openConnection();
    BufferedReader br=new BufferedReader(new InputStreamReader(url.openStream()));
    String line=null;
    while((line=br.readLine())!=null){
    System.out.println(line);
    }
    }catch(Exception e){
    e.printStackTrace();
    }
    }}
      

  2.   

    package net;import com.jacob.activeX.ActiveXComponent;
    import com.jacob.com.Dispatch;
    import com.jacob.com.Variant;public class JacobIE { /**
     * @param args
     */

    // ie:{0002DF01-0000-0000-C000-000000000046}
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    ActiveXComponent ie = new ActiveXComponent("clsid:0002DF01-0000-0000-C000-000000000046");
          Object ieo = ie.getObject();
          try {
            Dispatch.put(ieo, "Visible", new Variant(true));
            Dispatch.put(ieo, "AddressBar", new Variant(true));
            Dispatch.put(ieo, "StatusText", new Variant("My Status Text"));
      
            Dispatch.call(ieo, "Navigate", new Variant("d:/2.html"));
          } catch (Exception e) {
            e.printStackTrace();
          } 
    }}
    不知道是不是这个意思,用jacob可以运行ie程序打开d:/2.html这个文件,运行上面程序需要下载jacob,在项目导入jacob.jar,拷贝jacob.dll到system32里面就ok了
      

  3.   

    Runtime.getRuntime().exec( "\""+System.getenv("ProgramFiles")+"\\Internet Explorer\\IEXPLORE.EXE\"  本地文件名" ); // 路径中若有空格必须用双引号括起来,而字符串常量中的双引号必须用反斜杠转义// 本地文件名可以为:D:\mydoc\myhtml.html (注意如果是字符串常量,反斜杠必须写两个——“\\”),也可以为: file:///D:/mydoc/myhtml.html