Here you can find the source of truncateInt(String intStr)
Parameter | Description |
---|---|
intStr | a parameter |
public static int truncateInt(String intStr)
//package com.java2s; //License from project: Apache License public class Main { /**//from ww w .j a va 2 s . c o m * * @param intStr * @return */ public static int truncateInt(String intStr) { int len = intStr.length(); int result = 0; for (int i = 0; i < len; i++) { char c = intStr.charAt(i); if (c >= '0' && c <= '9') { result = result * 10; result += c - '0'; } else { break; } } return result; } }