Pulling values from a Java Properties file in order?

前端 未结 15 776
庸人自扰
庸人自扰 2020-12-02 18:32

I have a properties file where the order of the values is important. I want to be able to iterate through the properties file and output the values based on the order of the

15条回答
  •  囚心锁ツ
    2020-12-02 19:15

    Apache Commons Configuration might do the trick for you. I haven't tested this myself, but I checked their sources and looks like property keys are backed by LinkedList in AbstractFileConfiguration class:

    public Iterator getKeys()
    {
        reload();
        List keyList = new LinkedList();
        enterNoReload();
        try
        {
            for (Iterator it = super.getKeys(); it.hasNext();)
            {
                keyList.add(it.next());
            }
    
            return keyList.iterator();
        }
        finally
        {
            exitNoReload();
        }
    }
    

提交回复
热议问题