public final class Reader extends Object implements 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(File database)
Constructs a Reader for the MaxMind DB format.
|
Reader(File database,
Reader.FileMode fileMode)
Constructs a Reader for the MaxMind DB format.
|
Reader(InputStream source)
Constructs a Reader as if in mode
Reader.FileMode.MEMORY, without using
a File instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
/**
|
com.fasterxml.jackson.databind.JsonNode |
get(InetAddress ipAddress)
Looks up the
address in the MaxMind DB. |
Metadata |
getMetadata() |
public Reader(File database) throws IOException
database - the MaxMind DB file to use.IOException - if there is an error opening or reading from the file.public Reader(InputStream source) throws IOException
Reader.FileMode.MEMORY, without using
a File instance.source - the InputStream that contains the MaxMind DB file.IOException - if there is an error reading from the Stream.public Reader(File database, Reader.FileMode fileMode) throws IOException
database - the MaxMind DB file to use.fileMode - the mode to open the file with.IOException - if there is an error opening or reading from the file.public com.fasterxml.jackson.databind.JsonNode get(InetAddress ipAddress) throws IOException
address in the MaxMind DB.ipAddress - the IP address to look up.IOException - if a file I/O error occurs.public Metadata getMetadata()
public void close()
throws 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 Closeableclose in interface AutoCloseableIOException - if an I/O error occurs.Copyright © 2015 MaxMind, Inc.. All Rights Reserved.