public static String optionallyPrependSlash ( final String path ) { // Adjust null String resolved = path ; if ( resolved == null ) { resolved = EMPTY ; } // If the first character is not a slash if ( ! isFirstCharSlash ( resolved ) ) { // Prepend the slash return ArchivePath . SEPARATOR + resolved ; } // Return as-is return resolved ; }
Adds if not already present the absolute slash preceding the specified path and returns the adjusted result . If the argument is null adjusts to an empty String before processing .