private boolean validateFilePath ( String filePath ) { if ( filePath == null || filePath . isEmpty ( ) ) { throw new IllegalArgumentException ( "filePath must be a valid filePath within the file system." ) ; } // Check if the filename exists as a File -- use an absolute file to ensure we have // a parent: even if that parent is ${user.dir} ... File loc = new File ( filePath ) . getAbsoluteFile ( ) ; return ( loc . exists ( ) || loc . getParentFile ( ) . exists ( ) ) ; }
The specified filePath must either exist or in the case the file should be created its parent directory .