如何通过java程序在mac上打开挂载磁盘?

时间:2017-07-21 12:12:01

标签: java macos mount dmg

我正在下载dmg文件,然后尝试通过java代码自动打开安装程序。

我可以下载该文件,然后使用“hdiutil attach file.dmg”挂载它。

  

使用网址,输入流和输出流下载文件

     

按以下方式安装dmg:    / usr / bin / hdiutil attach file.dmg

我无法打开此挂载的磁盘,以便安装程序出现在前台。有关如何做到这一点的任何想法?

谢谢!

Harsha P

1 个答案:

答案 0 :(得分:0)

执行open /Volumes/VolumeName,然后打开它的finder文件夹

或使用osascript运行applescript,以便在需要时将finder置于前台:

property the_path : "/Volumes/MyMacDrive/Mani/WorkSpace/" set the_folder to (POSIX file the_path) as alias tell application "Finder" activate if window 1 exists then set target of window 1 to the_folder else reveal the_folder end if end tell