Here you can find the source of startsWithAny(String s, List
public static boolean startsWithAny(String s, List<String> prefixes)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2009 Oracle. 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. * //from w w w. j a v a 2 s. c o m * Contributors: * Oracle - initial API and implementation ******************************************************************************/ import java.util.List; public class Main { /** * Tests whether a string starts with any of a list of strings. */ public static boolean startsWithAny(String s, List<String> prefixes) { int count = prefixes.size(); for (int i = 0; i < count; ++i) { if (s.startsWith((String) prefixes.get(i))) { return true; } } return false; } }