/*
* OpenWord.java
*
* Created on 2007年9月26日, 下午9:02
*
*desktop.open方法有些文件格式打不开,还不是很好用,没Runtime.getRuntime().exec("命令");这个方法用得广
* and open the template in the editor.
*/
package technologylearn;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import org.omg.SendingContext.RunTime;
public class OpenWord{
public static void main(String[] a) {
try {
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
desktop.open(new File("G://a.doc“));
} catch (IOException e) {
ioe.printStackTrace();
}
}
}
* OpenWord.java
*
* Created on 2007年9月26日, 下午9:02
*
*desktop.open方法有些文件格式打不开,还不是很好用,没Runtime.getRuntime().exec("命令");这个方法用得广
* and open the template in the editor.
*/
package technologylearn;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import org.omg.SendingContext.RunTime;
public class OpenWord{
public static void main(String[] a) {
try {
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
desktop.open(new File("G://a.doc“));
} catch (IOException e) {
ioe.printStackTrace();
}
}
}
本文介绍了一种使用Java代码来打开本地Word文档的方法。通过利用Java的Desktop类,可以实现跨平台地调用桌面应用程序来打开指定路径的文档。本文提供了具体的代码示例,并讨论了这种方法的一些局限性。
914

被折叠的 条评论
为什么被折叠?



