[java] How to avoid Number Format Exception in java?