Here you can find the source of substringBetween(final String str, final String startToken, final String endToken)
public static String substringBetween(final String str, final String startToken, final String endToken)
//package com.java2s; /**//from w w w. j a v a 2s .c om * Confidential Information. * Copyright (C) 2007-2009 Eric Link, All rights reserved. * PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. **/ public class Main { public static String substringBetween(final String str, final String startToken, final String endToken) { //-1 if not found int firstToken = str.indexOf(startToken) + 1; int secondToken = str.indexOf(endToken, firstToken); // make safe if not found firstToken = firstToken < 0 ? 0 : firstToken; secondToken = secondToken < 0 ? 0 : secondToken; return str.substring(firstToken, secondToken); } }