Example usage for java.lang String endsWith

List of usage examples for java.lang String endsWith

Introduction

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

Prototype

public boolean endsWith(String suffix) 

Source Link

Document

Tests if this string ends with the specified suffix.

Usage

From source file:Main.java

public static String[] getPuzzleFiles(Context context) {
    String[] files = context.fileList();
    Vector<String> puzzleFiles = new Vector<String>();
    for (String file : files)
        if (file.endsWith(".pfy"))
            puzzleFiles.add(file);//from   w w w . jav  a2  s .  c  o m
    String[] ret = new String[0];
    return puzzleFiles.toArray(ret);
}

From source file:Main.java

public static String getFileMineType(String filePath) {
    if (filePath.endsWith(".jpg") || filePath.endsWith("jpeg")) {
        return "image/jpeg";
    }/*w  ww.  ja v  a2 s  .c o  m*/
    if (filePath.endsWith(".png")) {
        return "image/png";
    }

    else if (filePath.endsWith(".gif")) {
        return "image/gif";
    }

    return null;

}

From source file:Main.java

public static boolean fileIsAudio(String fileName) {
    return fileName != null && fileName.endsWith(".3gp");
}

From source file:Main.java

private static boolean isGif(String string2) {
    if (string2 != null && string2.endsWith(".gif")) {
        return true;
    }//from   w  ww.  j  av a2  s. c  om
    return false;
}

From source file:Main.java

public static boolean isStringType(String typeName) {
    return typeName.endsWith("String");

}

From source file:Main.java

public static boolean fileIsVideo(String fileName) {
    return fileName != null && (fileName.endsWith(".mp4") || fileName.endsWith(".MP4"));
}

From source file:Main.java

public static boolean isPicture(String fileName) {
    return fileName.endsWith(".jpg") || fileName.endsWith(".png") || fileName.endsWith(".jpeg")
            || fileName.endsWith(".JPG") || fileName.endsWith(".PNG") || fileName.endsWith(".JPEG")
            || fileName.endsWith(".bmp") || fileName.endsWith(".gif") || fileName.endsWith(".webp");
}

From source file:Main.java

public static String filePathAddEndSprit(String filePath) {
    if (null != filePath && !filePath.endsWith("/"))
        return filePath + "/";
    return filePath;
}

From source file:Main.java

public static String plural(String s) {
    if (s.endsWith("y"))
        return s.substring(0, s.length() - 1) + "ies";
    else if (s.endsWith("us"))
        return s.substring(0, s.length() - 2) + "i";
    else if (s.endsWith("ch") || s.endsWith("x") || s.endsWith("s") || s.endsWith("sh"))
        return s + "es";
    else if (s.endsWith("f"))
        return s.substring(0, s.length() - 1) + "ves";
    else if (s.endsWith("man") || s.endsWith("Man"))
        return s.substring(0, s.length() - 2) + "en";
    else/*  ww w. ja  v  a 2 s.co  m*/
        return s + "s";
}

From source file:Main.java

public static boolean fileIsImage(String fileName) {
    return fileName != null && (fileName.endsWith(".jpg") || fileName.endsWith(".JPG")
            || fileName.endsWith(".png") || fileName.endsWith(".PNG"));
}