Here you can find the source of substringBetween(String s, String part1, String part2)
public static String substringBetween(String s, String part1, String part2)
//package com.java2s; public class Main { public static String substringBetween(String s, String part1, String part2) { String sub = null;//from ww w . j a v a 2s .c om int i = s.indexOf(part1); int j = s.indexOf(part2, i + part1.length()); if (i != -1 && j != -1) { int nStart = i + part1.length(); sub = s.substring(nStart, j); } return sub; } }