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

public static boolean isVideoLink(String url) {
    url = extractDomain(url, true);/*from   w w  w  .j  a v a  2  s .  c om*/
    return url.startsWith("youtube.com") || url.startsWith("video.yahoo.com") || url.startsWith("vimeo.com")
            || url.startsWith("blip.tv");
}

From source file:Main.java

public static String getParakeetURL(Context context) {
    String my_receivers = PreferenceManager.getDefaultSharedPreferences(context)
            .getString("wifi_recievers_addresses", "").trim();
    if (my_receivers.equals(""))
        return null;

    String[] hosts = my_receivers.split(",");
    if (hosts.length == 0)
        return null;

    for (String host : hosts) {
        host = host.trim();/*from  w ww.  j  av  a2  s . c  o m*/
        if ((host.startsWith("http://") || host.startsWith("https://"))
                && (host.contains("/json.get") || host.contains("Parakeet"))) {
            return host;
        }
    }
    return null;
}

From source file:Main.java

public static boolean isSupportRange(final HttpResponse response) {
    if (response == null)
        return false;
    Header header = response.getFirstHeader("Accept-Ranges");
    if (header != null) {
        return "bytes".equals(header.getValue());
    }/*from  w w w. j a v a  2s .  c o  m*/
    header = response.getFirstHeader("Content-Range");
    if (header != null) {
        String value = header.getValue();
        return value != null && value.startsWith("bytes");
    }
    return false;
}

From source file:Main.java

/**
 * Returns true if the given filePath refers a text file.
 *//*www. ja va  2  s. c o m*/
public static boolean isTextFile(String filePath) {
    String contentType = getContentTypeForFilePath(filePath);
    return contentType.startsWith("text/");
}

From source file:Main.java

public static String getBeforeSeparatorOrNothing(String name) {
    int index = name.indexOf(SEPARATOR);
    if (index == -1 || name.startsWith(SEPARATOR))
        return "";
    else//ww  w .  ja  v  a 2 s . c o m
        return name.substring(0, index);
}

From source file:Main.java

public static List<Component> findComponentsNameStartsWith(Container rootComponent, String startsWith,
        List<Component> res) {
    if (rootComponent instanceof Container) {
        Component[] components = ((Container) rootComponent).getComponents();
        for (Component comp : components) {
            String name = comp.getName();
            if (name != null && name.startsWith(startsWith))
                res.add(comp);/*from   w  ww.  j a  va  2 s . c  om*/
            if (comp instanceof Container)
                findComponentsNameStartsWith((Container) comp, startsWith, res);
        }
    }
    return res;
}

From source file:Main.java

/**
 * Returns true if the given filePath refers an image file.
 *///from   w  w w. j  av  a  2 s  . c o  m
public static boolean isImageFile(String filePath) {
    String contentType = getContentTypeForFilePath(filePath);
    return contentType.startsWith("image/");
}

From source file:com.parallax.server.blocklyprop.jsp.Properties.java

public static String getDownloadFilesBaseUrl(String file) {
    return configuration.getString("downloadfiles.baseurl") + (file.startsWith("/") ? "" : "/") + file;
}

From source file:com.smartitengineering.util.bean.ResourceFactory.java

public static Resource getResource(final String resource) {
    if (StringUtils.isNotBlank(resource) && resource.startsWith(PropertiesLocator.CLASSPATH_RESOURCE_PREFIX)) {
        return new ClasspathResource(resource);
    } else if (StringUtils.isNotBlank(resource)) {
        return new FileSystemResource(resource);
    }//from   www. j  a va 2s  . co  m
    return null;
}

From source file:Main.java

/**
 * Checks current locale settings to select a language which should be used for communication with MCI.
 * /* w  w  w .  j  a  va  2s.  c o m*/
 * @return Code of language to use for MCI communication
 */
public static final String getMciLanguageCode() {
    String lowerLanguage = Locale.getDefault().getLanguage().toLowerCase(Locale.US);
    if (lowerLanguage.startsWith("cs") || lowerLanguage.startsWith("sk")) {
        return "cs";
    } else {
        return "en";
    }
}