// Using a Permission to check if a given operation would succeed without
// actually attemping it.

FilePermission permission = new FilePermission( "C:/-", "write" );
try
   {
   AccessController.checkPermission( permission );
   // Add Save button only if can write to disk
   panel.add( new JButton( "Save" ) );
   }
catch ( AccessControlException e )
   {
   // would not be able to write
   }