Thursday 9 May 2019

How to get string if length is more than 50 after 50 it split into another string ?

String st = "A string is a data type used in programming,
 such as an integer and floating point unit,
but is used to represent text rather than numbers";
if (st.length() > 50) {
    int comma = st.indexOf(',', 50);
    if (comma >= 0) {

        //Bit before comma        String partOne = st.substring(0, comma);

        //Bit after comma        String partTwo = st.substring(comma);
        Log.e("string partOne", partOne);
        Log.e("string partTwo", partTwo);
    }
}

No comments:

Post a Comment