File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ CHANGELOG
66
77* IMPORTANT: Java 7 is now required. If you need Java 6 support, please
88 continue using 1.2.2 or earlier.
9+ * The method ` getRecord ` was added to ` com.maxmind.db.Reader ` . This method
10+ returns a ` com.maxmind.db.Record ` object that includes the data for the
11+ record as well as the network associated with the record.
912
10131.2.2 (2017-02-22)
1114------------------
Original file line number Diff line number Diff line change @@ -62,15 +62,22 @@ read in metadata for the file.
6262
6363``` java
6464File database = new File (" /path/to/database/GeoIP2-City.mmdb" );
65- Reader reader = new Reader (database);
65+ try ( Reader reader = new Reader (database)) {
6666
67- InetAddress address = InetAddress . getByName(" 24.24.24.24" );
67+ InetAddress address = InetAddress . getByName(" 24.24.24.24" );
6868
69- JsonNode response = reader. get(address);
69+ // get() returns just the data for the associated record
70+ JsonNode recordData = reader. get(address);
7071
71- System . out. println(response );
72+ System . out. println(recordData );
7273
73- reader. close();
74+ // getRecord() returns a Record class that contains both
75+ // the data for the record and associated metadata.
76+ Record record = reader. getRecord(address);
77+
78+ System . out. println(record. getData());
79+ System . out. println(record. getNetwork());
80+ }
7481```
7582
7683### Caching ###
You can’t perform that action at this time.
0 commit comments