Java: storing a big map in resources
<p>I need to use a big file that contains String,String pairs and because I want to ship it with a JAR, I opted to include a serialized and gzipped version in the resource folder of the application. This is how I created the serialization:</p>

<pre><code>ObjectOutputStream out = new ObjectOutputStream(
            new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(OUT_FILE_PATH, false))));
out.writeObject(map);
out.close();
</code></pre>

<p>I chose to use a <code>HashMap&lt;String,String&gt;</code>, the resulting file is 60MB and the map contains about 4 million entries.</p>

<p>Now when I need the map and I deserialize it using:</p>

<pre><code>final InputStream in = FileUtils.getResource("map.ser.gz");
final ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new GZIPInputStream(in)));
map = (Map&lt;String, String&gt;) ois.readObject();
ois.close();
</code></pre>

<p>this takes about 10~15 seconds. Is there a better way to store such a big map in a JAR? I ask because I also use the Stanford CoreNLP library which uses big model files itself but seems to perform better in that regard. I tried to locate the code where the model files are read but gave up.</p>