用JAVA打开一个已经存在的word文档

解决方案 »

  1.   

    只要打开的话就这样了:
    String[] command = {"Word.exe","test.doc"};
    Runtime.getRuntime().exec(command);如果你想读写Word文件的话,PIO(http://jakarta.apache.org/poi/)是个不错的选择
      

  2.   

    f_acme(沧海一声笑) 
        兄弟我用你说的方法怎么不行啊!
     public static void main(String[] args) {
        String[] command = {"Word.exe", "F:\\xmlword\\test.doc"};
        try {
          Runtime.getRuntime().exec(command);
        }
        catch (IOException ex) {
          ex.printStackTrace();
        }
      }
      

  3.   

    打开word的方法只是调用了本地的office,所以你必须安装office,并且指定安装路径
        public static void main(String[] args)
        {
            String[] command =
                {
                "D:\\Program Files\\Microsoft Office\\Office10\\WINWORD.EXE", "e:\\a.doc"};
            try
            {
                Runtime.getRuntime().exec(command);
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
            }
        }
    如果要在程序中操作word文档,就要用到poi的jar了,具体用法可以查找poi的说明文件