Open any file or folder using Desktop class

Complete source code below will show you, how to open C:\ drive using Desktop class. Desktop class is only can get when you use jdk 6.

******************************************************************
COMPLETE SOURCE CODE FOR : OpenFileUsingDesktopClass.java
******************************************************************


/*
*If you want to use Desktop class,
*you must make sure that jdk version
*that you use is 6. This facilities
*is exist in jdk 6.
*/
import java.awt.Desktop;

import java.io.File;

public class OpenFileUsingDesktopClass
{
public static void main(String[]args)
{
try
{
//Open C:\ drive
//Make sure that you change \ to \\
//You can change to other file or folder that you want
//Example for file that you want to open:
//C:\Sunset.jpg
//So, change C:\\ below to
//C:\\Sunset.jpg
Desktop.getDesktop().open(new File("C:\\"));
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}


******************************************************************
JUST COMPILE AND EXECUTE IT
******************************************************************


Click here to download jdk6
Click here to download jdk6 documentation

RELAXING NATURE VIDEO