Java tutorial
//package com.java2s; public class Main { static int getMajorVersionNumberInternal(String version) { if (!version.equals("@" + "version" + "@")) { try { int firstDot = version.indexOf("."); String majorStr = version.substring(0, firstDot); return new Integer(majorStr).intValue(); } catch (NumberFormatException nfe) { } } // in case this is a mainline version or NFE was caught (strange) return 2; } }