public static void createNewFile ( @ NonNull final File file , final boolean overwrite ) throws IOException { Condition . INSTANCE . ensureNotNull ( file , "The file may not be null" ) ; boolean result = file . createNewFile ( ) ; if ( ! result ) { if ( overwrite ) { try { delete ( file ) ; createNewFile ( file , false ) ; } catch ( IOException e ) { throw new IOException ( "Failed to overwrite file \"" + file + "\"" ) ; } } else if ( file . exists ( ) ) { throw new IOException ( "File \"" + file + "\" does already exist" ) ; } else { throw new IllegalArgumentException ( "The file must not be a directory" ) ; } } }
Creates a new empty file .