Example usage for java.lang String startsWith

List of usage examples for java.lang String startsWith

Introduction

In this page you can find the example usage for java.lang String startsWith.

Prototype

public boolean startsWith(String prefix) 

Source Link

Document

Tests if this string starts with the specified prefix.

Usage

From source file:Main.java

/**
 * Removes the leading slash if found on the passed in filename.
 * @param fileName/*from  w w  w . j  av  a2s  .  c  om*/
 */
public static String removeLeadingUnixSlash(String fileName) {
    if (fileName.startsWith("/")) {
        return fileName.substring(1);
    }
    return fileName;
}

From source file:Main.java

/**
 * Adds the leading slash if needed on the beginning of a filename.
 * @param fileName/*  w  w w  .  ja v a 2  s .  c  o  m*/
 */
public static String addLeadingUnixSlash(String fileName) {
    if (fileName.startsWith("/")) {
        return fileName;
    }
    return "/" + fileName;
}

From source file:Main.java

/**
 * Determine if a baseUrl string is in absolute or relative form. A empty string
 * "" or null para will return false.//  w  w  w  .j  a v  a 2 s  . c  om
 * 
 * @param url
 *            url string.
 * @return true if it is a absolute path starting with "http://" or
 *         "https://", case ignored.
 */
public static boolean isAbsoluteUrl(String url) {
    if (isEmpty(url)) {
        return false;
    } else {
        String lowerUrl = url.trim().toLowerCase();
        return lowerUrl.startsWith("http://") || lowerUrl.startsWith("https://");
    }
}

From source file:Main.java

public static List<String> extractUrl(String text) {
    List<String> urls = new ArrayList<>();
    Matcher matcher = Patterns.WEB_URL.matcher(text);
    while (matcher.find()) {
        int start = matcher.start();
        if (start > 0 && text.charAt(start - 1) == '@') {
            continue;
        }//from w w  w  .j av  a2 s  . c om
        String url = matcher.group();
        if (!url.startsWith("http")) {
            url = "http://" + url;
        }
        urls.add(url);
    }
    return urls;
}

From source file:Main.java

/**
 * Remove any authorisation details from a URI
 *///from   w  ww  . j a va  2  s  .  c o  m
public static String removeAuthorisation(String uri) {
    if (uri.indexOf("@") != -1 && (uri.startsWith("ftp://") || uri.startsWith("http://"))) {
        return uri.substring(0, uri.indexOf(":") + 2) + uri.substring(uri.indexOf("@") + 1);
    }

    return uri;
}

From source file:com.germinus.easyconf.JndiURL.java

public static boolean isJndi(String sourcePath) {
    return sourcePath.startsWith(JNDI_PREFIX);
}

From source file:com.semsaas.utils.anyurl.App.java

private static boolean checkProducerBased(String target) {
    return target.startsWith("http");
}

From source file:com.taobao.tddl.common.SQLPreParserTest.java

private static boolean isCRUD0(String sql) {
    if (!sql.startsWith("begin") && !sql.startsWith("declare") && !sql.startsWith("lock")
            && !sql.startsWith("merge") && !sql.startsWith("explain") && !sql.startsWith("call")
            && !sql.startsWith("alter") && !sql.startsWith("sql_text") && !sql.startsWith("with")
            && !sql.startsWith("create")) {
        return true;
    }//from www.  j a  v a 2 s  .  com
    return false;
}

From source file:Main.java

/**
 * Converts a method name to a Java attribute name, e.g. getFooBar() --> fooBar, isFlag --> flag.
 * @param methodName/*from   w w w  .j  a v  a2 s.  co m*/
 * @return
 */
public static String methodNameToJavaAttributeName(final String methodName) {
    String name = methodName;
    if ((methodName.startsWith("get") || methodName.startsWith("set")) && methodName.length() > 3)
        name = methodName.substring(3);
    else if (methodName.startsWith("is") && methodName.length() > 2)
        name = methodName.substring(2);

    if (Character.isUpperCase(name.charAt(0)))
        return name.substring(0, 1).toLowerCase() + name.substring(1);
    return name;
}

From source file:Main.java

private static boolean hasUTF8BOM(File f) throws FileNotFoundException, IOException {
    FileInputStream fis = new FileInputStream(f);
    BufferedReader br = new BufferedReader(new InputStreamReader(fis, Charset.forName("UTF-8")));
    String s = br.readLine();
    boolean ret = false;
    if (s.startsWith(UTF8_BOM))
        ret = true;/* w ww.j  a va  2 s  . co m*/

    br.close();
    return ret;
}