How to read a file once and use it many times?

Viewed 44

I have a java program that uses RoWordNet(which is wordnet for Romania). The problem is that every time I run the program it takes 1 minute to load the database. I want to load it only at the first execution and then use it for every execution without loading it again.Is there a solution for this? Thanks. Code:

import data.*;
import io.*;
import java.util.ArrayList;
public class main {

    public static void main(final String[] args) throws Exception {


        IO.outln("Loading RoWordNet ...");
        // to read from XML : 
        // RoWordNet rown = new RoWordNet(XMLRead.read("res\\rown.xml"));
        // to read from raw (serialized) object : 
        // this is the line with reading
        RoWordNet rown = RoWordNet.deserializeFromFile("RoWordNet\\res\\RoWordNet.data");
        Literal l1 = new Literal("magazin");
        ArrayList<Synset> arr = rown.getSynsetsFromLiteral(l1);
        int dim =arr.size();
        ArrayList<String>  justLiterals = new ArrayList<String>();
        for(int i=0;i<dim;i++)
        {
            ArrayList<Literal> literalsWithSense = new ArrayList<Literal>();
            literalsWithSense=(ArrayList<Literal>)arr.get(i).getLiterals();


            int numOfLiterals=literalsWithSense.size();
            for (int j=0;j<numOfLiterals;j++)
            {
                String literal=new String();
                literal=literalsWithSense.get(j).getLiteral();
                if (! justLiterals.contains(literal)){
                    justLiterals.add(literal);
                }

            }
        }

        System.out.println(justLiterals);
    }
}
0 Answers
Related