簡體   English   中英

在遠程數據庫中打開文件

[英]Opening file in Remote Database

我有 java 桌面應用程序,其中有文件上傳和查看功能。 這是我打開文件的代碼

 public static boolean open(File file) {
    OSDetector osdetector = new OSDetector();
    try {
        if (osdetector.isWindows()) {
            Runtime.getRuntime().exec(new String[]{"rundll32", "url.dll,FileProtocolHandler",
                file.getAbsolutePath()});
            return true;
        } else if (osdetector.isLinux() || osdetector.isMac()) {
            Runtime.getRuntime().exec(new String[]{"/usr/bin/open",
                file.getAbsolutePath()});
            return true;
        } else // Unknown OS, try with desktop
        if (Desktop.isDesktopSupported()) {
            Desktop.getDesktop().open(file);
            return true;
        } else {
            return false;
        }
    } catch (Exception e) {
        e.printStackTrace(System.err);
        return false;
    }
}

這在 MAC OS 中完美運行,但是當我在 Windows 7 PC 中運行時,它不會打開文件。 以下是錯誤信息;

Adobe 閱讀器錯誤: “打開此文檔時出錯。此文件已打開或已被其他應用程序使用”

Windows 照片查看器錯誤消息: “Windows 照片查看器無法打開此圖片,因為該圖片正在另一個程序中編輯”

繪制錯誤消息: “訪問時發生共享沖突......”

請幫忙

謝謝你

Windows 無法處理兩個程序同時使用一個文件的想法,大概是由於它的 DOS 單用戶起源。 確保在保存文件時,調用open()方法之前將其關閉。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM