将字符串开头空格去掉 @param str @return
(String str)
| 309 | * @return |
| 310 | */ |
| 311 | public static String trimStart(String str) { |
| 312 | if (str == "" || str == null) { |
| 313 | return str; |
| 314 | } |
| 315 | |
| 316 | final char[] value = str.toCharArray(); |
| 317 | int start = 0, last = 0 + str.length(); |
| 318 | int end = last; |
| 319 | while ((start <= end) && (value[start] <= ' ')) { |
| 320 | start++; |
| 321 | } |
| 322 | if (start == 0 && end == last) { |
| 323 | return str; |
| 324 | } |
| 325 | if (start >= end) { |
| 326 | return ""; |
| 327 | } |
| 328 | return str.substring(start, end); |
| 329 | } |
| 330 | } |
no outgoing calls