is this what ur looking for???
Code:class RangeEntry { long a, z; String cty_code; }; public class IP_Tracer { protected Vector<RangeEntry> ranges; public IP_Tracer(String arg_filename) throws IOException { FileInputStream fis; DataInputStream dis; BufferedReader br; fis = new FileInputStream(arg_filename); dis = new DataInputStream(fis); br = new BufferedReader( new InputStreamReader(dis) ); String str; while ( (str = br.readLine()) != null ) { if ( str.length() < 18 ) // Start off with aa,1.1.1.1,1.1.1.1 continue; RangeEntry re = new RangeEntry(); re.cty_code = str.substring(0,1); str = str.substring(3); // Leaves us with 1.1.1.1,1.1.1.1 String a = str.substring( 0, str.indexOf(',') - 1 ); String z = str.substring( str.indexOf(',') + 1 ); re.a = Long.valueOf(a); re.z = Long.valueOf(z); ranges.add(re); } } String IP_to_Country( long ip ) { for ( RangeEntry re : ranges ) { if ( ip >= re.a && ip <= re.z ) return re.cty_code; } return null; } };