Example usage for java.lang String compareTo

List of usage examples for java.lang String compareTo

Introduction

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

Prototype

public int compareTo(String anotherString) 

Source Link

Document

Compares two strings lexicographically.

Usage

From source file:Main.java

public static boolean isInStartEnd(String srcDate, String startDate, String endDate) {
    if (startDate.compareTo(srcDate) <= 0 && endDate.compareTo(srcDate) >= 0) {
        return true;
    } else {/* w w w .j a v  a2s. c  o  m*/
        return false;
    }
}

From source file:Main.java

/**
 * This method is responsible to convert the SW1 and SW2 bytes, received with an response APDU into 
 * more significant text explanations./*from   ww  w  . j a  va 2  s  .com*/
 * 
 * @param apdu the APDU received from the card in hex-format.
 * @return the hex-APDU with an additional text-explanation.
 */
public static String APDUtoText(String apdu) {
    if (apdu.compareTo("9000") == 0)
        return new String(apdu + " - Command executed successful!");
    if (apdu.compareTo("6e00") == 0)
        return new String(apdu + " - Class not supported!");
    return apdu;
}

From source file:Main.java

public static Boolean isLessThanEqual(String hashVal1, String hashVal2) {
    int compareVal = hashVal1.compareTo(hashVal2);
    if (compareVal <= 0) {
        return true;
    } else {/*from w w  w .  ja  v a  2s. c o  m*/
        return false;
    }
}

From source file:Main.java

/**
 * This method checks that the file is accepted by the filter
 * //from  w w w . j a va2s.co m
 * @param file
 *            - file that will be checked if there is a specific type
 * @param filter
 *            - criterion - the file type(for example ".jpg")
 * @return true - if file meets the criterion - false otherwise.
 */
@SuppressLint("DefaultLocale")
public static boolean accept(final File file, final String filter) {
    if (filter.compareTo(FILTER_ALLOW_ALL) == 0) {
        return true;
    }
    if (file.isDirectory()) {
        return true;
    }
    int lastIndexOfPoint = file.getName().lastIndexOf('.');
    if (lastIndexOfPoint == -1) {
        return false;
    }
    String fileType = file.getName().substring(lastIndexOfPoint).toLowerCase();
    return fileType.compareTo(filter) == 0;
}

From source file:Main.java

public static Date convertStringDateToDate(String date) {
    try {// w w  w .  jav  a 2 s.  c  o  m
        if (date != null && date.compareTo("null") != 0 && date.compareTo("") != 0) {
            if (date.length() > 11) {
                return (Date) new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.getDefault()).parse(date);
            } else {
                return (Date) new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(date);
            }
        }
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static String getLocalIpAddress() {
    try {/*from w  ww.j a v  a  2s.  c  om*/
        Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
        while (en.hasMoreElements()) {
            NetworkInterface intf = en.nextElement();
            String name = intf.getName();
            if (name.compareTo("eth0") == 0 || name.compareTo("wlan0") == 0) {
                Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses();
                while (enumIpAddr.hasMoreElements()) {
                    InetAddress inetAddress = enumIpAddr.nextElement();
                    if (inetAddress.getClass() == Inet4Address.class) {
                        return inetAddress.getHostAddress();
                    }
                }
            }
        }
    } catch (SocketException ex) {
        Log.e("MY", ex.toString());
    }
    return null;
}

From source file:com.opensmile.maven.ClassifierFactory.java

static public Classifier createClassifier(String name, logger logger_instance) {
    if (name.compareTo("opensmilesvm") == 0) {
        Classifier c = new openSMILEclassifier();
        c.logger_instance = logger_instance;
    }//from w  w  w  .j  a v a2  s.c  o  m
    return null;
}

From source file:com.gson.util.Tools.java

public static final boolean checkSignature(String token, String signature, String timestamp, String nonce) {
    List<String> params = new ArrayList<String>();
    params.add(token);//w  w w. j  ava 2s  . c o m
    params.add(timestamp);
    params.add(nonce);
    Collections.sort(params, new Comparator<String>() {
        @Override
        public int compare(String o1, String o2) {
            return o1.compareTo(o2);
        }
    });
    String temp = params.get(0) + params.get(1) + params.get(2);
    return DigestUtils.shaHex(temp).equals(signature);
}

From source file:Main.java

public static boolean isFeatureSupportedInVcenterApiVersion(String vCenterApiVersion,
        String minVcenterApiVersionForFeature) {
    return vCenterApiVersion.compareTo(minVcenterApiVersionForFeature) >= 0 ? true : false;
}

From source file:Main.java

public static String prepareFilePathForVideoSaveWithDraftUri(Uri draftUri) {
    String draftPath = draftUri.getPath();
    String draftMediaDirPath = draftPath.substring(0, draftPath.length() - 5);
    File draftMediaDir = new File(draftMediaDirPath);
    if (!draftMediaDir.exists()) {
        draftMediaDir.mkdirs();/*  ww w .j a v a 2  s .c om*/
    }
    String[] files = draftMediaDir.list(new FilenameFilter() {
        @Override
        public boolean accept(File dir, String filename) {
            return filename.endsWith("-0.mp4") || filename.endsWith("-a.mp4");
        }
    });
    List<String> filePaths = Arrays.asList(files);
    Collections.sort(filePaths, new Comparator<String>() {
        @Override
        public int compare(String lhs, String rhs) {
            return rhs.compareTo(lhs);
        }
    });
    if (filePaths.size() > 0) {
        for (String file : filePaths) {
            return new File(draftMediaDir, file.substring(0, file.length() - 6) + ".mp4").getAbsolutePath();
        }
    }
    return new File(draftMediaDir, generateRandomFilename("mp4")).getAbsolutePath();
}