long getTotalSpace() long getFreeSpace() long getUsableSpace() boolean setReadable( boolean) boolean setWritable( boolean) boolean setExecutable( boolean)
import java.io.*; public class DiskSpace { public static void main(String args[]) { File f = new File(args[0]); System.out.printf("Total Space : %d MB\n", f.getTotalSpace() / (1024 * 1024) ); System.out.printf("Available Space: %d MB\n", f.getFreeSpace() / (1024 * 1024) ); } }
import javax.swing.*; public class ShowSplash extends JFrame { public static void main(String args[]) throws Exception { Thread.sleep(1000); ShowSplash f = new ShowSplash(); f.setSize(200,200); f.setTitle("Splash Demo"); f.setVisible(true); f.setDefaultCloseOperation( EXIT_ON_CLOSE); } }
java -splash:logo.gif ShowSplash
void browse (URI ) void edit (File) void mail() void open (File) void print (File)
import java.awt.*; import java.net.*; import java.io.*; public class DesktopDemo { public static void main(String args[]) throws Exception { Desktop d = Desktop.getDesktop(); // get desktop object if ( args[0].equals("b")) // invoke browser d.browse( new URI(args[1])); else if ( args[0].equals("e")) d.edit( new File(args[1]) ); else if ( args[0].equals("o")) d.open( new File(args[1]) ); else d.print( new File(args[1])); } }
java DesktopDemo b readme.html
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class SystemTrayDemo { public static void main(String args[]) throws Exception { TrayIcon trayIcon = null; SystemTray tray = SystemTray.getSystemTray(); // load an image Image image = Toolkit.getDefaultToolkit().getImage("HOMELOGO.JPG"); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null,"Srikanth Technologies","Title",JOptionPane.INFORMATION_MESSAGE); } }; // create a popup menu PopupMenu popup = new PopupMenu(); // create menu item for the default action MenuItem defaultItem = new MenuItem("Srikanth Technologies"); MenuItem closeItem = new MenuItem("Close"); closeItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); defaultItem.addActionListener(listener); popup.add(defaultItem); popup.add(closeItem); trayIcon = new TrayIcon(image, "Srikanth Technologies", popup); trayIcon.setImageAutoSize(true); trayIcon.addActionListener(listener); tray.add(trayIcon); } }