public class LoadWinApp
{
    public static void main(String args[]) throws IOException
    {
        Runtime r = Runtime.getRuntime();
        Process p = null;
        String strWinApp = "cmd.exe start ";
        String strWinFile = "D:\\test.doc";        if(args.length > 0)
        {
            strWinFile = args[0];
        }
        try
        {
            p = r.exec(strWinApp + " " + strWinFile);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}先获取文件的路径名, 再把其中所有的 \ 换成 \\ 就可以啦。
用StringTokenizer s = new StringTokenizer (path,"\\");

解决方案 »

  1.   

    专门有一个包,叫什么都忘记了。你搜索一下,关键字:word。有很多人讲到过这个东西的。
      

  2.   

    看看这里的
    http://expert.csdn.net/Expert/topic/2231/2231433.xmlTO:cans(cans)
    你用了cmd.exe start还真是个不错的方法,省了主文件的定位
      

  3.   

    不明确楼主的意思,是在程序里获得doc文档的内容,还是让操作系统打开doc文档?
    如果后者,可以这样
    Runtime r = Runtime.getRuntime();
    Process p = r.exec("cmd.exe /c start a.doc");
    p.waitFor();