Open the default file explorerTag(s): IO

JDK1.6
Open the default file explorer.
import java.io.File;
import java.io.IOException;
import java.awt.Desktop;

public class Test {
  public static void main(String s[]) {
    Desktop desktop = null;
    // on Windows, retrieve the path of the "Program Files" folder
    File file = new File(System.getenv("programfiles"));
    if (Desktop.isDesktopSupported()) {
      desktop = Desktop.getDesktop();
    }
    try {
      desktop.open(file);
    }
    catch (IOException e){  }
  }
}

blog comments powered by Disqus


If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2012
[ home ]