Java String Leading Character addLeadingSlash(String fileName)

Here you can find the source of addLeadingSlash(String fileName)

Description

add Leading Slash

License

Apache License

Declaration

@Deprecated
public static String addLeadingSlash(String fileName) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from   ww  w .ja v a  2  s  .  c  o  m*/
     * @deprecated this is now just a pass-through to {@link #addLeadingUnixSlash(String, String)}. The original method was a
     * misnomer.
     */
    @Deprecated
    public static String addLeadingSlash(String fileName) {
        return addLeadingUnixSlash(fileName);
    }

    /**
     * Adds the leading slash if needed on the beginning of a filename.
     * @param fileName
     */
    public static String addLeadingUnixSlash(String fileName) {
        if (fileName.startsWith("/")) {
            return fileName;
        }
        return "/" + fileName;
    }
}

Related

  1. addLeadingCharacter(String s, char c, int len)
  2. addLeadingCharacter(String s, char c, int len)
  3. addLeadingSlash(String fileName)
  4. addLeadingSlash(String path)
  5. addLeadingSlash(String path)
  6. addLeadingSlash(String string)
  7. addLeadingSpace(String s, int len)