ini4j - How to get all the key names in a setting?

I couldn't find anything in the tutorials so I stepped through the source, until I found the entrySet method. With that you can do this:

Wini ini = new Wini(new File(...));
Set<Entry<String, Section>> sections = ini.entrySet(); /* !!! */

for (Entry<String, Section> e : sections) {
    Section section = e.getValue();
    System.out.println("[" + section.getName() + "]");

    Set<Entry<String, String>> values = section.entrySet(); /* !!! */
    for (Entry<String, String> e2 : values) {
        System.out.println(e2.getKey() + " = " + e2.getValue());
    }
}

This code essentially re-prints the .ini file to the console. Your sample file would produce this output: (the order may vary)

[food]
name = steak
type = american
price = 20.00
[school]
dept = cse
year = 2
major = computer_science

No guarantees on this one. Made it up in 5min. But it reads the ini you provided without further knowledge of the ini itself (beside the knowledge that it consists of a number of sections each with a number of options.

Guess you will have to figure out the rest yourself.

import org.ini4j.Ini;
import org.ini4j.Profile.Section;
import java.io.FileReader;

public class Test {
    public static void main(String[] args) throws Exception {
        Ini ini = new Ini(new FileReader("test.ini"));
        System.out.println("Number of sections: "+ini.size()+"\n");
        for (String sectionName: ini.keySet()) {
            System.out.println("["+sectionName+"]");
            Section section = ini.get(sectionName);
            for (String optionKey: section.keySet()) {
                System.out.println("\t"+optionKey+"="+section.get(optionKey));
            }
        }
    }
}

Check out ini4j Samples and ini4j Tutorials too. As often a not very well documented library.