Java String Starts Wtih startsWith(String text, String prefix, int toffset)

Here you can find the source of startsWith(String text, String prefix, int toffset)

Description

starts With

License

Open Source License

Declaration

public static boolean startsWith(String text, String prefix, int toffset) 

Method Source Code

//package com.java2s;
/***************************************************************************
 * Copyright 2001-2006 VietSpider         All rights reserved.  *
 * Please look at license.txt in info directory for more license detail.   *
 **************************************************************************/

public class Main {
    public static boolean startsWith(String text, String prefix, int toffset) {
        int po = 0;
        int pc = prefix.length();
        if (toffset < 0 || pc > text.length())
            return false;

        char ta[] = text.toCharArray();
        int to = toffset;
        char pa[] = prefix.toCharArray();

        while (--pc >= 0) {
            char c1 = ta[to++];
            char c2 = pa[po++];
            if (c1 == c2
                    || Character.toLowerCase(c1) == Character
                            .toLowerCase(c2))
                continue;
            return false;
        }// w w  w .j ava  2 s.  c  o m
        return true;
    }
}

Related

  1. startsWith(String str1Raw, String str2Raw)
  2. startsWith(String string, char... ca)
  3. startsWith(String string, String prefix)
  4. startsWith(String string, StringBuffer prefix, int toffset)
  5. startsWith(String target, String... prefixes)
  6. startsWith(String toTest, String[] possibilities)
  7. startsWith(String value, String startsWith)
  8. startsWith(String[] array, String obj)
  9. startsWith(String[] beginningSegments, String[] testSegments)