Using just re-arranged the parameters

Posted on 2007-10-12
Last Modified: 2013-12-29
I need a way to store and retrieve parameters from a config. file using java Properties but keeping the order, line spaces and comments in the configuration files.

Question by:bachra04
    LVL 92

    Expert Comment

    then you'll need to load it yourself into a LinkedHashMap
    LVL 92

    Expert Comment

    Maybe even an ArrayList if you want to also store the comment.
    LVL 92

    Expert Comment

    LVL 2

    Author Comment

    what about the comments and spaces between lines that I want to keep.
    LVL 92

    Accepted Solution

    you can use split to split the lines

    String[] keyvalue = line.split("=");
    String key = keyvalue[0];
    String value = keyvalue[1];
    LVL 92

    Expert Comment

    > what about the comments and spaces between lines that I want to keep.

    thats why i said you may need to use a List
    see the link for how to read file into list

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    withoutTen challenge 14 68
    maxMirror challenge 10 68
    java  and programming certification ? 4 29
    Unable to start eclipse ? 17 45
    If you have upgraded to Java2 update 10 on a Microsoft Windows client, you may have discovered that your Java application does not work as it did before.  For example, the colors of your Java2D graphic may be all wrong for no apparent reason. Aft…
    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now