Java String Sub String substring(String s, int start)

Here you can find the source of substring(String s, int start)

Description

substring

License

Open Source License

Declaration

public static String substring(String s, int start) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 BSI Business Systems Integration AG.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://from   ww w  . j  ava  2  s .  co m
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

public class Main {
    public static String substring(String s, int start) {
        if (s == null || start >= s.length()) {
            return "";
        }
        return s.substring(start);
    }

    public static String substring(String s, int start, int len) {
        if (s == null || start >= s.length()) {
            return "";
        }
        len = Math.min(s.length() - start, len);
        return s.substring(start, start + len);
    }

    public static int length(String s) {
        if (s == null) {
            return 0;
        } else {
            return s.length();
        }
    }
}

Related

  1. subString(String parentStr, String startStr, String endStr)
  2. substring(String S, int beginIndex, int endIndex)
  3. substring(String s, int beginIndex, int endIndex)
  4. substring(String s, int i, String substring, int direction)
  5. subString(String s, int length)
  6. substring(String s, int start, int length)
  7. substring(String s, int start, int stop)
  8. subString(String s, int startIndex, int count)
  9. substring(String self, Integer startIndex, Integer endIndex)