Java String Ends With endsWith(String fullString, String subString)

Here you can find the source of endsWith(String fullString, String subString)

Description

Null Pointer proof String.endsWith() method.

License

Apache License

Parameter

Parameter Description
fullString a parameter
subString a parameter

Return

true if no argument is NULL and fullString.endsWith(subString)==true

Declaration

public static boolean endsWith(String fullString, String subString) 

Method Source Code

//package com.java2s;
/*//from   ww  w  . j a  v a 2  s .  co  m
 * Copyright 2012-2014 Netherlands eScience Center.
 *
 * 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 the following location:
 *
 *     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.
 * 
 * For the full license, see: LICENSE.txt (located in the root folder of this distribution).
 * ---
 */

public class Main {
    /**
     * Null Pointer proof String.endsWith() method. First argument is complete
     * string and second argument is the substring which the first argument
     * should end with. If either strings is NULL, false is returned.
     * 
     * @param fullString
     * @param subString
     * @return true if no argument is NULL and
     *         fullString.endsWith(subString)==true
     */
    public static boolean endsWith(String fullString, String subString) {
        if (fullString == null)
            return false;

        if (subString == null)
            return false;

        return fullString.endsWith(subString);
    }
}

Related

  1. endsWith(final StringBuilder builder, final char match)
  2. endsWith(int[] data, int[] ends)
  3. endsWith(String a, char[] b)
  4. endsWith(String baseString, String compareString)
  5. endsWith(String filePath, String extension)
  6. endsWith(String haystack, String needle)
  7. endsWith(String in, String str)
  8. endsWith(String inEnd, String inValue)
  9. endsWith(String receiver, String... needles)