Here you can find the source of subString(String text, String leadingPart)
Parameter | Description |
---|---|
text | a parameter |
leadingPart | a parameter |
public static String subString(String text, String leadingPart)
//package com.java2s; /******************************************************************************* * Copyright (c) 2008 flowr.org - all rights reserved. This program and the accompanying materials are made available * under the terms of the Eclipse Public License (EPL) v1.0. The EPL is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: flowr.org - initial API and implementation ******************************************************************************/ public class Main { /**//from ww w .j a v a 2s . co m * gets the substring of the given text reduced by the given leading part. * * @param text * @param leadingPart * @return the reduced substring, if the text starts with the given leading part; otherwise the incoming, unmodified * text. */ public static String subString(String text, String leadingPart) { if (text.startsWith(leadingPart)) { return text.substring(leadingPart.length()); } else { return text; } } /** * gets the substring of the given text reduced by the number of leading and tailing characters. * * @param text the String to reduce * @param lead number of characters to remove at the leading end * @param tail number of characters to remove at the tailing end * @return the reduced substring, reduced by <code>lead</code> chars at the begin and <code>tail</code> chars at the * end. * @throws StringIndexOutOfBoundsException */ public static String subString(String text, int lead, int tail) { return text.substring(lead, text.length() - tail); } }