How to organise files.

Discussion in 'Plugin Development' started by Joey Clover, Mar 17, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Joey Clover

    I have made a file called EggSpawner.config. I set properties in the order I want them to appear in the list:
    Code:
            props.load(new FileInputStream(file));
            props.setProperty("CHICKEN", "true");
            props.setProperty("PIGZOMBIE", "false");
            props.setProperty("GHAST", "false");
            props.setProperty("SHEEP", "false");
            props.setProperty("SQUID", "false");
            props.setProperty("ZOMBIE", "false");
            props.setProperty("SKELETON", "false");
            props.setProperty("SPIDER", "false");
            props.setProperty("COW", "false");
            props.setProperty("CREEPER", "false");
            props.setProperty("PIG", "false");
            props.setProperty("SPAWN_CHANCE", "5");
    However, when I look at the file created, it appears like this:
    Code:
    CREEPER=false
    COW=false
    SPAWN_CHANCE=5
    CHICKEN=true
    SHEEP=false
    PIGZOMBIE=false
    GHAST=false
    ZOMBIE=false
    SPIDER=false
    SKELETON=false
    SQUID=false
    PIG=false
    
    How can I make the file appear like I want it to?

    please help asap

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 12, 2016
  2. Offline

    Plague

    I don'T think the property system is implemented in a way that you would say in which order it's saved. If you need it in order you can parse it yourself.
     
  3. Offline

    Joey Clover

    How? :/
     
  4. Offline

    Waterwolf

    What exactly you want to do? Change appearance or order of properties?
     
  5. Offline

    Mixcoatl

    The java.util.Properties class derives from java.util.Hashtable. The keys are unordered. The code to order the keys and write out the file is fairly trivial. Properly escaping keys and values is a little more complicated, but might not be necessary for your purposes.
     
Thread Status:
Not open for further replies.

Share This Page