synchronized void _check_mtime() { try { if ((dboptions & GEOIP_CHECK_CACHE) != 0) { long t = databaseFile.lastModified(); if (t != mtime) { /* GeoIP Database file updated */ /* refresh filehandle */ close(); file = new RandomAccessFile(databaseFile, "r"); databaseInfo = null; init(); } } } catch (IOException e) { throw new InvalidDatabaseException("Database not found", e); } }
@Override public void teardown() { reader.close(); }
@Override public void teardown() { reader.close(); }
synchronized void _check_mtime(){ try { if ((dboptions & GEOIP_CHECK_CACHE) != 0){ long t = databaseFile.lastModified(); if (t != mtime){ /* GeoIP Database file updated */ /* refresh filehandle */ close(); file = new RandomAccessFile(databaseFile,"r"); databaseInfo = null; init(); } } } catch (IOException e) { System.out.println("file not found"); } }
synchronized void _check_mtime(){ try { if ((dboptions & GEOIP_CHECK_CACHE) != 0){ long t = databaseFile.lastModified(); if (t != mtime){ /* GeoIP Database file updated */ /* refresh filehandle */ close(); file = new RandomAccessFile(databaseFile,"r"); databaseInfo = null; init(); } } } catch (IOException e) { System.out.println("file not found"); } }
synchronized void _check_mtime() { try { if ((dboptions & GEOIP_CHECK_CACHE) != 0) { long t = databaseFile.lastModified(); if (t != mtime) { /* GeoIP Database file updated */ /* refresh filehandle */ close(); file = new RandomAccessFile(databaseFile, "r"); databaseInfo = null; init(); } } } catch (IOException e) { System.out.println("file not found"); } }
synchronized void _check_mtime() { try { if ((dboptions & GEOIP_CHECK_CACHE) != 0) { long t = databaseFile.lastModified(); if (t != mtime) { /* GeoIP Database file updated */ /* refresh filehandle */ close(); file = new RandomAccessFile(databaseFile, "r"); databaseInfo = null; init(); } } } catch (IOException e) { throw new InvalidDatabaseException("Database not found", e); } }
synchronized void _check_mtime() { try { if ((dboptions & GEOIP_CHECK_CACHE) != 0) { long t = databaseFile.lastModified(); if (t != mtime) { /* GeoIP Database file updated */ /* refresh filehandle */ close(); file = new RandomAccessFile(databaseFile, "r"); databaseInfo = null; init(); } } } catch (IOException e) { throw new InvalidDatabaseException("Database not found", e); } }
import com.maxmind.geoip.*; import java.io.IOException; class CountryLookupTest { public static void main(String[] args) { try { String sep = System.getProperty("file.separator"); String dir = "C:/Program Files/Apache Software Foundation/Tomcat 7.0/GeoIP"; String dbfile = dir + sep + "GeoIP.dat"; LookupService cl = new LookupService(dbfile,LookupService.GEOIP_MEMORY_CACHE); System.out.println(cl.getCountry("151.38.39.114").getCode()); System.out.println(cl.getCountry("151.38.39.114").getName()); System.out.println(cl.getCountry("12.25.205.51").getName()); System.out.println(cl.getCountry("64.81.104.131").getName()); System.out.println(cl.getCountry("200.21.225.82").getName()); cl.close(); } catch (IOException e) { System.out.println("IO Exception"); } } }
ls.close(); ls = null;
} finally { if (lookupService != null) { lookupService.close();