日期:2014-05-17  浏览次数:20632 次

JAVA直接本地HTML和TXT文件。
/**
     * 直接打开本地文件
     * */
private void openFile(String localFileUrl) {
String filename = "openFile.bat";

File file = new File(filename);
try {
//创建本地批处理文件
FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter writer = new OutputStreamWriter(fos, "GB2312");
writer.append(localFileUrl + " start");
writer.close();
fos.close();

//执行批处理文件
Runtime.getRuntime().exec(filename);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}