ImportJava.awt.Desktop;ImportJava.io.File;Importjava.io.IOException; Public classLnkdemo { Public Static voidMain (string[] args)throwsIOException {File f=NewFile ("D://com.lnk"); System.out.println (F.exists ()); System.out.println (F.isdirectory ()); Runtime.getruntime (). EXEC ("Explorer/e,/select," +F.getabsolutepath ());//desktop.getdesktop (). open (f); }}
Summary
This article describes the command line for Explorer.exe (Resource manager).
Grammar
EXPLORER. EXE [/n][/e][,/root,<object>][[,/select],<sub Object>]
/N: The default option, use My Computer view to open a separate window for each item selected, even if the window is already open.
/E: Use Explorer view. Explorer view is very similar to the File Manager for Windows 3.x.
/root,<object>: Specifies the view directory root, which uses the desktop as the root directory by default.
/select,<sub object>: Select the specified object. If you use "/select", the parent directory is opened and the specified object is selected .
Example
Open Explorer View and browse with C:\Windows as directory root
Explorer/e,/root,c:\windows
Open Explorer View and select Calc.exe
Explorer/e,/select,c:\windows\system32\calc.exe
Note:/root and/select should not be used at the same time.
Http://www.cnblogs.com/ymind/archive/2012/03/30/explorer-command-args.html
Two ways to open a file in Java