public static File validateSettingsDirectory(File dir) throws IOException {
  dir=dir.getAbsoluteFile();
  if (!dir.isDirectory()) {
    dir.delete();
    if (!dir.mkdirs())     throw new IOException("could not create preferences directory: " + dir);
  }
  if (!dir.canWrite())   throw new IOException("settings dir not writable: " + dir);
  if (!dir.canRead())   throw new IOException("settings dir not readable: " + dir);
  File file=File.createTempFile("test","test",dir);
  if (!file.exists())   throw new IOException("can't write test file in directory: " + dir);
  file.delete();
  return dir;
}

public static File validateSettingsDirectory ( File dir ) throws IOException { dir = dir . getAbsoluteFile ( ) ; if ( ! dir . isDirectory ( ) ) { dir . delete ( ) ; if ( ! dir . mkdirs ( ) ) throw new IOException ( "could not create preferences directory: " + dir ) ; } if ( ! dir . canWrite ( ) ) throw new IOException ( "settings dir not writable: " + dir ) ; if ( ! dir . canRead ( ) ) throw new IOException ( "settings dir not readable: " + dir ) ; File file = File . createTempFile ( "test" , "test" , dir ) ; if ( ! file . exists ( ) ) throw new IOException ( "can't write test file in directory: " + dir ) ; file . delete ( ) ; return dir ; }
validates a potential settings directory . this returns the validated directory , or throws an ioexception if it can ' t be validated .
