androidstring-utils

StringUtils class not working in Android


I am using StringUtils class in Android code. but exception generated i.e. class not found. But already i used jar file for that class. Please help me!


Solution

  • My problem solved with following code, We need not use StringUtils jar to add our project.

    I create my own class i.e "RanjitString" replace with StringUtils.

    public class RanjitString {
    public static String substringBetween(String str, String open, String close) {
        if (str == null || open == null || close == null) {
            return null;
        }
        int start = str.indexOf(open);
        if (start != -1) {
            int end = str.indexOf(close, start + open.length());
            if (end != -1) {
                return str.substring(start + open.length(), end);
            }
        }
        return null;
    }
    }
    

    And directly access the static method substringBetween:

    String myxml="This is my xml with different tags";
    String successResult = RanjitString.substringBetween(myxml,
                    "<tag>", "</tag>");
    

    This code is working for me...