import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
public class JavaDesktop {
private static void access() {
try {
URI uri = new URI("http://www.what21.com");
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
if (desktop != null) {
desktop.browse(uri);
}
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (URISyntaxException use) {
use.printStackTrace();
}
}
private static void open() {
try {
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
desktop.open(new File("c:\\a.txt"));
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
private static void edit() {
try {
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
desktop.edit(new File("c:\\a.txt"));
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
private static void print() {
try {
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
desktop.print(new File("c:\\a.txt"));
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
/**
* @param args
*/
public static void main(String[] args) {
access();
open();
edit();
print();
}
}