public static String cut(final String version,final int parts){
  int pos=0;
  for (int i=0; i < parts; i++) {
    final int temp=version.indexOf(".",pos + 1);
    if (temp < 0) {
      pos=version.length();
      break;
    }
    pos=temp;
  }
  return version.substring(0,pos);
}

public static String cut ( final String version , final int parts ) { int pos = 0 ; for ( int i = 0 ; i < parts ; i ++ ) { final int temp = version . indexOf ( "." , pos + 1 ) ; if ( temp < 0 ) { pos = version . length ( ) ; break ; } pos = temp ; } return version . substring ( 0 , pos ) ; }
extract the specified number of parts from a version - string .
