Here you can find the source of lengthOfStartingWhitespace(String s)
public static int lengthOfStartingWhitespace(String s)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); public class Main { /**//from w w w . jav a 2 s . co m * @return the length of the starting whitespace for the line, or the string * length if it is all whitespace */ public static int lengthOfStartingWhitespace(String s) { int n = s.length(); for (int i = 0; i < n; i++) { char c = s.charAt(i); // TODO: This currently only deals with ASCII whitespace. // Read until a non-space if (c != ' ' && c != '\t') { return i; } } return n; } }