Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7538889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:14:10+00:00 2026-05-30T07:14:10+00:00

I am trying to generate a properties file for a mod I’m making for

  • 0

I am trying to generate a properties file for a mod I’m making for Minecraft.

The mod will rely a lot of this properties file. It should look something like this:

#Comment
#More Comment
#Even more comment explaining.

Button1=Button1   #The data after the equals they would change
Button1Command=/help
Button2=Button2
Button2Command=/rules

This would repeat for over 30 button. Here is a test code I used to generate 19 of these options in the config:

    Properties p = new Properties();

    try {
        File configDir = new File(Minecraft.getMinecraftDir(), "/config/");
        File config = new File(configDir, "FogHelperConfig.cfg");
        // set the properties value
        for(int c = 18;c >= 0;c--)
        {
        p.setProperty("Button"+c, "Button"+c);
        }
        // save properties minecraft config folder.
        p.store(new FileOutputStream(config), null);

    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

The output for this

Button18=Button18
Button17=Button17
Button9=Button9
Button16=Button16
Button8=Button8
Button15=Button15
Button7=Button7
Button14=Button14
Button6=Button6
Button13=Button13
Button5=Button5
Button12=Button12
Button4=Button4
Button11=Button11
Button3=Button3
Button10=Button10
Button2=Button2
Button1=Button1
Button0=Button0

Of course this is a major problem when I’m dealing with something needs to be in a logical order because it has numbering. I can see this being okay if there were no numbers but in this case it MUST be in order.

I’m assuming there is something I can do or some kind of workaround to fix this issue that the Java Properties class has. I’m willing to have a properties file that I would handmake and package with the mod and just have it placed in a specific location, though I’d prefer to have it generated as it’s more user friendly.

Also another thing I would need to do is add comments to this prop file though I’m not quite sure how to.

Any different ways to do this are welcome! Whatever works!

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:14:12+00:00Added an answer on May 30, 2026 at 7:14 am

    i used the code below to good effect. the natural sort order was good enough for me. you might have to name you buttons like “Button01”.

    import java.io.StringWriter;
    import java.util.*;
    public class SortedProperties extends Properties {
        @Override public Set<Object> keySet() {
            return Collections.unmodifiableSet(new TreeSet<Object>(super.keySet()));
        }
        @Override public synchronized Enumeration<Object> keys() {
            return Collections.enumeration(new TreeSet<Object>(super.keySet()));
        }
        public static void main(String[] args) throws Exception {
            Properties properties = new SortedProperties() {
                {
                    for (int c = 18; c >= 0; c--) {
                        String name = "Button" + (c < 10 ? "0" : "") + c;
                        put(name, name);
                    }
                }
            };
            StringWriter stringWriter = new StringWriter();
            properties.store(stringWriter, "foo");
            System.err.println(stringWriter.toString());
        }
        private static final long serialVersionUID = 1L;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI, I have a typical messages.properties file in my application. I'm trying to generate
I'm trying to create a C# console application that will generate a log file.
While trying to generate classes from a xsd, i got this error: java.lang.IllegalArgumentException: Illegal
I'm trying to generate customized xml files from a template xml file in python.
I am trying to generate a Sandcastle help file for a website. In the
I'm trying to write a macro that will generate a plain-text list of files
I am trying to generate a report by querying 2 databases (Sybase) in classic
I'm trying to generate a sitemap.xml on the fly for a particular asp.net website.
I am trying to generate equivalent MD5 hashes in both JavaScript and .Net. Not
I'm trying to generate a unique ID in php in order to store user-uploaded

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.