Example usage for java.lang String substring

List of usage examples for java.lang String substring

Introduction

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

Prototype

public String substring(int beginIndex, int endIndex) 

Source Link

Document

Returns a string that is a substring of this string.

Usage

From source file:Main.java

public static String getTimestamp() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US);
    sdf.setTimeZone(TimeZone.getDefault());
    String tmp = sdf.format(new Date());
    tmp = tmp.substring(0, 22) + ":" + tmp.substring(22);
    return tmp;/*from  ww w .  j  a va 2 s  .  co  m*/
}

From source file:Main.java

public static String getMIMEType(File var0) {
    String var1 = "";
    String var2 = var0.getName();
    String var3 = var2.substring(var2.lastIndexOf(".") + 1, var2.length()).toLowerCase();
    var1 = MimeTypeMap.getSingleton().getMimeTypeFromExtension(var3);
    return var1;
}

From source file:Main.java

public static Integer[] getColorRGB(String hex) {

    return new Integer[] { Integer.valueOf(hex.substring(0, 2), 16), Integer.valueOf(hex.substring(2, 4), 16),
            Integer.valueOf(hex.substring(4, 6), 16) };
}

From source file:com.espe.distribuidas.protocolocajero.pc.Mensaje.java

public static boolean validaHash(String trama) {
    String cuerpo = trama.substring(85, trama.length());
    String md5HashN = DigestUtils.md5Hex(cuerpo);
    String md5Hash = trama.substring(53, 85);
    //        if(md5Hash.equals(md5HashN))
    //            System.out.println("correctooooo");
    return md5Hash.equals(md5HashN);
}

From source file:Main.java

public static String classNameForPath(String classPath) {
    String className = classPath.substring(0, classPath.length() - ".class".length());
    return className.replace(File.separatorChar, '.');
}

From source file:Main.java

public static String getTruncatedString(String str) {
    if (str.length() > 8)
        return str.substring(0, 5) + "...";
    return str;/*from   w  w w . j  a v a  2 s .  c  o m*/
}

From source file:Main.java

public static String replaceImgSuffix(String imgUrl) {
    String frontPartUrl = imgUrl.substring(0, imgUrl.lastIndexOf(".") + 1);
    String preSuffix = imgUrl.substring(imgUrl.lastIndexOf(".") + 1);
    String hindSuffix = "jpg";
    if (preSuffix.toLowerCase().equals("jpg")) {
        hindSuffix = "png";
    } else if (preSuffix.toLowerCase().equals("png")) {
        hindSuffix = "jpg";
    }/*from w w w. jav  a  2 s  .  co  m*/
    String newImgUrl = frontPartUrl + hindSuffix;

    return newImgUrl;
}

From source file:Main.java

public static byte[] IpPortStringToBytes(String ipportString) {
    String[] strs = ipportString.substring(0, ipportString.indexOf(":")).split("[.]");
    byte[] b = new byte[strs.length + 2];
    int index = 0;

    for (String str : strs) {
        b[index++] = (byte) (Integer.parseInt(str));
    }//from  ww w .j  a v  a2 s . co m
    String[] port = ipportString.split("[:]");
    b[index++] = (byte) ((Integer.parseInt(port[1]) & 0x00FF));
    b[index++] = (byte) ((Integer.parseInt(port[1]) & 0xFF00) >> 8);
    return b;
}

From source file:Main.java

private static String getResourceName(String resourceName) {
    String rn = new String(resourceName.substring(0, 1).toLowerCase() + resourceName.substring(1));
    rn = rn.replaceAll(" ", "");
    for (int i = 'A'; i <= 'Z'; i++) {
        char ch = (char) i;
        String s = new String(ch + "");
        rn = rn.replaceAll(s, "_" + s.toLowerCase());
    }//  www  .j a  v  a2s  .  c  om
    return rn;
}

From source file:Main.java

public static String getImagePath(String remoteUrl) {
    String imageName = remoteUrl.substring(remoteUrl.lastIndexOf("/") + 1, remoteUrl.length());
    /*   String path = PathUtil.getDbManager().getImagePath() + "/" + imageName;
       EMLog.d("msg", "image path:" + path);*/
    return null;/*from  www . j  a  v  a  2  s .co m*/

}