I need to use a large file containing String, String strings, and since I want to send it using the JAR, I decided to include the serialized and gzipped version in the application resource folder. This is how I created serialization:
ObjectOutputStream out = new ObjectOutputStream( new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(OUT_FILE_PATH, false)))); out.writeObject(map); out.close();
I decided to use HashMap<String,String> , the resulting file is 60 MB, and the map contains about 4 million records.
Now that I need a card and I deserialize it using:
final InputStream in = FileUtils.getResource("map.ser.gz"); final ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new GZIPInputStream(in))); map = (Map<String, String>) ois.readObject(); ois.close();
It takes about 10 ~ 15 seconds. Is there a better way to store such a large card in a JAR? I ask because I also use the Stanford CoreNLP library, which itself uses large model files, but seems to work better in this regard. I tried to find the code in which the model files would be read, but gave up.
source share