從桌面用默認程序打開file

import java.awt.Desktop;
import java.io.*;java

public static void main(String[] args) {
  // TODO Auto-generated method stub
  Desktop desktop = null;
  try{ this

    // Before more Desktop API is used, first check spa

    // whether the API is supported by this particular code

    // virtual machine (VM) on this particular host.get

    if (Desktop.isDesktopSupported()) {
      desktop = Desktop.getDesktop();
      desktop.open(new File("/home/illy/song.mp3"));
    }
   }
  catch (IOException e) {
    e.printStackTrace();
   }
}io

相關文章
相關標籤/搜索