Android String Cut cutStringFromChar(String str1, String str2, int offset)

Here you can find the source of cutStringFromChar(String str1, String str2, int offset)

Description

cut String From Char

License

Apache License

Declaration

public static String cutStringFromChar(String str1, String str2,
        int offset) 

Method Source Code

//package com.java2s;
/****************************************************************************
 *            Copyright (C) 2014 www.apkdv.com
 *    Author: LengYue  ProjectName: DvTools
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License./*from   ww w  .  j  av a2 s .  c  o  m*/
 *****************************************************************************/

public class Main {

    public static String cutStringFromChar(String str1, String str2,
            int offset) {
        if (isEmpty(str1)) {
            return "";
        }

        int start = str1.indexOf(str2);

        if (start != -1) {
            if (str1.length() > start + offset) {
                return str1.substring(start + offset);
            }
        }

        return "";
    }

    public static boolean isEmpty(String str) {
        return (str == null) || (str.trim().length() == 0);
    }
}

Related

  1. cutStringFromChar(String str1, String str2, int offset)
  2. cutRight(final String srcStr, final String cutStr)
  3. cutoff(String value, int length)
  4. cutString(String str, int length)
  5. cutString(String str, int length, String dot)