Runtime.getRuntime()。exec没有打开文件

时间:2015-09-20 19:47:19

标签: java windows runtime.exec

我希望在从数据库获取路径时打开此pdf文件。我正确地从数据库中获取文件的文件路径,但不会打开FileProtocoleHandler。这是代码

public void actionPerformed(ActionEvent event) {
    try {
        String sql = "SELECT Pictures FROM equipments WHERE Type= ?";
        PreparedStatement update = con.prepareStatement(sql);
        int row = table.getSelectedRow();
        update.setString(1, (String) table.getValueAt(row, 5));
        ResultSet result = update.executeQuery();
        if (result.next()) {

            String path = result.getString("Pictures");
            System.out.println(path);
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocoleHandler" + path);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
});

0 个答案:

没有答案