I have a lot of code that gathers user input and parses it, I want to parse integer values without throwing exceptions.
My current tryParseInt()
function is code is simple:
public static Integer tryParseInt( String text )
{
if(text == null)
return null;
try
{
return new Integer( text.trim() );
}
catch ( NumberFormatException e )
{
return null;
}
}
But i am getting lots of NumberFormatExceptions
and i am worried becouse that may impact my app performance.
Can anyone suggest me on best practice for parsing user inputs.
Thank you