/** * Gets the path from a full filename, which excludes the prefix. * <p> * This method will handle a file in either Unix or Windows format. * The method is entirely text based, and returns the text before and * including the last forward or backslash. * <pre>{@code * C:\a\b\c.txt --> a\b\ * ~/a/b/c.txt --> a/b/ * a.txt --> "" * a/b/c --> a/b/ * a/b/c/ --> a/b/c/ * }</pre> * <p> * The output will be the same irrespective of the machine that the code is running on. * <p> * This method drops the prefix from the result. * See {@link #getFullPath(String)} for the method that retains the prefix. * * @param filename the filename to query, null returns null * @return the path of the file, an empty string if none exists, null if invalid */ public static String getPath(String filename) { return doGetPath(filename, 1); }
/** * Gets the path from a full filename, which excludes the prefix, and * also excluding the final directory separator. * <p> * This method will handle a file in either Unix or Windows format. * The method is entirely text based, and returns the text before the * last forward or backslash. * <pre>{@code * C:\a\b\c.txt --> a\b * ~/a/b/c.txt --> a/b * a.txt --> "" * a/b/c --> a/b * a/b/c/ --> a/b/c * }</pre> * <p> * The output will be the same irrespective of the machine that the code is running on. * <p> * This method drops the prefix from the result. * See {@link #getFullPathNoEndSeparator(String)} for the method that retains the prefix. * * @param filename the filename to query, null returns null * @return the path of the file, an empty string if none exists, null if invalid */ public static String getPathNoEndSeparator(String filename) { return doGetPath(filename, 0); }
/** * Gets the path from a full filename, which excludes the prefix, and * also excluding the final directory separator. * <p> * This method will handle a file in either Unix or Windows format. * The method is entirely text based, and returns the text before the * last forward or backslash. * <pre>{@code * C:\a\b\c.txt --> a\b * ~/a/b/c.txt --> a/b * a.txt --> "" * a/b/c --> a/b * a/b/c/ --> a/b/c * }</pre> * <p> * The output will be the same irrespective of the machine that the code is running on. * <p> * This method drops the prefix from the result. * See {@link #getFullPathNoEndSeparator(String)} for the method that retains the prefix. * * @param filename the filename to query, null returns null * @return the path of the file, an empty string if none exists, null if invalid */ public static String getPathNoEndSeparator(final String filename) { return doGetPath(filename, 0); }
/** * Gets the path from a full filename, which excludes the prefix. * <p> * This method will handle a file in either Unix or Windows format. * The method is entirely text based, and returns the text before and * including the last forward or backslash. * <pre>{@code * C:\a\b\c.txt --> a\b\ * ~/a/b/c.txt --> a/b/ * a.txt --> "" * a/b/c --> a/b/ * a/b/c/ --> a/b/c/ * }</pre> * <p> * The output will be the same irrespective of the machine that the code is running on. * <p> * This method drops the prefix from the result. * See {@link #getFullPath(String)} for the method that retains the prefix. * * @param filename the filename to query, null returns null * @return the path of the file, an empty string if none exists, null if invalid */ public static String getPath(final String filename) { return doGetPath(filename, 1); }
/** * Gets the path from a full filename, which excludes the prefix, and * also excluding the final directory separator. * <p> * This method will handle a file in either Unix or Windows format. * The method is entirely text based, and returns the text before the * last forward or backslash. * <pre>{@code * C:\a\b\c.txt --> a\b * ~/a/b/c.txt --> a/b * a.txt --> "" * a/b/c --> a/b * a/b/c/ --> a/b/c * }</pre> * <p> * The output will be the same irrespective of the machine that the code is running on. * <p> * This method drops the prefix from the result. * See {@link #getFullPathNoEndSeparator(String)} for the method that retains the prefix. * * @param filename the filename to query, null returns null * @return the path of the file, an empty string if none exists, null if invalid */ public static String getPathNoEndSeparator(final String filename) { return doGetPath(filename, 0); }
/** * Gets the path from a full filename, which excludes the prefix. * <p> * This method will handle a file in either Unix or Windows format. * The method is entirely text based, and returns the text before and * including the last forward or backslash. * <pre>{@code * C:\a\b\c.txt --> a\b\ * ~/a/b/c.txt --> a/b/ * a.txt --> "" * a/b/c --> a/b/ * a/b/c/ --> a/b/c/ * }</pre> * <p> * The output will be the same irrespective of the machine that the code is running on. * <p> * This method drops the prefix from the result. * See {@link #getFullPath(String)} for the method that retains the prefix. * * @param filename the filename to query, null returns null * @return the path of the file, an empty string if none exists, null if invalid */ public static String getPath(final String filename) { return doGetPath(filename, 1); }