public final class Reader
extends java.lang.Object
implements java.io.Closeable
get method.| Modifier and Type | Class and Description |
|---|---|
static class |
Reader.FileMode
The file mode to use when opening a MaxMind DB.
|
| Constructor and Description |
|---|
Reader(java.io.File database)
Constructs a Reader for the MaxMind DB format, with no caching.
|
Reader(java.io.File database,
NodeCache cache)
Constructs a Reader for the MaxMind DB format, with the specified backing
cache.
|
Reader(java.io.File database,
Reader.FileMode fileMode)
Constructs a Reader for the MaxMind DB format, with no caching.
|
Reader(java.io.File database,
Reader.FileMode fileMode,
NodeCache cache)
Constructs a Reader for the MaxMind DB format, with the specified backing
cache.
|
Reader(java.io.InputStream source)
Constructs a Reader with no caching, as if in mode
Reader.FileMode.MEMORY, without using a File instance. |
Reader(java.io.InputStream source,
NodeCache cache)
Constructs a Reader with the specified backing cache, as if in mode
Reader.FileMode.MEMORY, without using a File instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the database.
|
com.fasterxml.jackson.databind.JsonNode |
get(java.net.InetAddress ipAddress)
Looks up
ipAddress in the MaxMind DB. |
Metadata |
getMetadata() |
Record |
getRecord(java.net.InetAddress ipAddress)
Looks up
ipAddress in the MaxMind DB. |
public Reader(java.io.File database)
throws java.io.IOException
database - the MaxMind DB file to use.java.io.IOException - if there is an error opening or reading from the file.public Reader(java.io.File database,
NodeCache cache)
throws java.io.IOException
database - the MaxMind DB file to use.cache - backing cache instancejava.io.IOException - if there is an error opening or reading from the file.public Reader(java.io.InputStream source)
throws java.io.IOException
Reader.FileMode.MEMORY, without using a File instance.source - the InputStream that contains the MaxMind DB file.java.io.IOException - if there is an error reading from the Stream.public Reader(java.io.InputStream source,
NodeCache cache)
throws java.io.IOException
Reader.FileMode.MEMORY, without using a File instance.source - the InputStream that contains the MaxMind DB file.cache - backing cache instancejava.io.IOException - if there is an error reading from the Stream.public Reader(java.io.File database,
Reader.FileMode fileMode)
throws java.io.IOException
database - the MaxMind DB file to use.fileMode - the mode to open the file with.java.io.IOException - if there is an error opening or reading from the file.public Reader(java.io.File database,
Reader.FileMode fileMode,
NodeCache cache)
throws java.io.IOException
database - the MaxMind DB file to use.fileMode - the mode to open the file with.cache - backing cache instancejava.io.IOException - if there is an error opening or reading from the file.public com.fasterxml.jackson.databind.JsonNode get(java.net.InetAddress ipAddress)
throws java.io.IOException
ipAddress in the MaxMind DB.ipAddress - the IP address to look up.java.io.IOException - if a file I/O error occurs.public Record getRecord(java.net.InetAddress ipAddress) throws java.io.IOException
ipAddress in the MaxMind DB.ipAddress - the IP address to look up.Record will still be returned.java.io.IOException - if a file I/O error occurs.public Metadata getMetadata()
public void close()
throws java.io.IOException
Closes the database.
If you are using FileMode.MEMORY_MAPPED, this will
not unmap the underlying file due to a limitation in Java's
MappedByteBuffer. It will however set the reference to
the buffer to null, allowing the garbage collector to
collect it.
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException - if an I/O error occurs.Copyright © 2020 MaxMind, Inc.. All Rights Reserved.