Java tutorial
//package com.java2s; public class Main { public static Number string2number(final String iText) { if (iText.indexOf('.') > -1) return Double.parseDouble(iText); else return Long.parseLong(iText); } }