// Package

// Imports
import org.ini4j.Ini;
import org.ini4j.Ini.Section;
import java.io.*;
import java.util.*;

/**
 * INI File Tester
 * <p>
 * Tests INI file reading
 * <p>
 * Licensed under <A HREF="http://www.gnu.org/licenses/gpl.txt">GNU GPL (Version 3)</A>. 
 * <p>
 * @author	Keripo
 * @version	1.0 17-Dec-07
 */

public class IniTest {

	// Variables
	private static File foo;
	private static FileInputStream bar;
	private static Ini ini;
	
	// Code

	public static void main(String[] args) {
		try {
			foo = new File("test.ini");
			bar = new FileInputStream(foo);
			ini = new Ini();
			ini.load(bar);
			
			// Special section
			Section list = ini.get("list");
			
			// Tokenize the section names
			StringTokenizer base = new StringTokenizer(list.fetch("base"));
			StringTokenizer packs = new StringTokenizer(list.fetch("packs"));
			
			// Make arraylist of sections
			ArrayList<Section> baseList = new ArrayList<Section>();
			ArrayList<Section> packList = new ArrayList<Section>(); 
			

			while (packs.hasMoreTokens()) {
				packList.add(ini.get(packs.nextToken()));
			}

			for (Section sec: packList) {
				System.out.println(sec.fetch("name"));
				System.out.println(sec.fetch("description"));
				System.out.println(sec.fetch("authors"));
				System.out.println(sec.fetch("download"));
				System.out.println(sec.fetch("links"));
				System.out.println("============");
			}
			
			System.out.println("Done");
			System.exit(0);
			
		} catch (Exception e) {
			System.err.println(e.getMessage());
		}
	}

}
