com.alarexgroup.m2mplf.file
Class INIFile

java.lang.Object
  extended by com.alarexgroup.m2mplf.file.INIFile
public class INIFile
extends java.lang.Object

This class works with INI files.

Example:

Loading ofinformation from file with following content.

[SMS]
sms1=+420777123456
sms2=+420777654321

[AUTH]
user=paja
passw=jaja


import com.alarexgroup.m2mplf.M2Mlet;
import com.alarexgroup.m2mplf.file.INIFile;

public class INIExample extends M2Mlet {
    String sms1, sms2, password, name;

    public INIExample() {
    }

    public void appStart() {
        INIFile ini = new INIFile("a:/m2m.ini");
        if (ini.load()){
            sms1 = ini.getValue("SMS","sms1");
            sms2 = ini.getValue("SMS","sms2");
            
            jmeno = ini.getValue("AUTH","user");
            heslo = ini.getValue("AUTH","passw");
        }
    }

    public void appPause() {
    }

    public void appStop(boolean unconditional) {
    }

}

Constructor Summary
INIFile(java.lang.String filename)
          Creates INI file in memory.
 
Method Summary
 java.lang.String getValue(java.lang.String groupName, java.lang.String key)
          Method returns value of key in section
 boolean load()
          Loads INI file from file system.
 void putValue(java.lang.String groupName, java.lang.String key, java.lang.String value)
          Saves combinaton of key and value into INI section.
 boolean save()
          Saves INI file into file system.
 boolean saveAs(java.lang.String filename)
          Saves INI with choosen name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

INIFile

public INIFile(java.lang.String filename)
Creates INI file in memory.

Parameters:
filename - - for example "myapplication_configuration.ini"
Method Detail

load

public boolean load()
Loads INI file from file system.

Returns:
success

saveAs

public boolean saveAs(java.lang.String filename)
Saves INI with choosen name.

Parameters:
filename - jméno INI souboru
Returns:
true - success

save

public boolean save()
Saves INI file into file system.

Returns:
true - success

putValue

public void putValue(java.lang.String groupName,
                     java.lang.String key,
                     java.lang.String value)
Saves combinaton of key and value into INI section.

Parameters:
groupName -
key -
value -

getValue

public java.lang.String getValue(java.lang.String groupName,
                                 java.lang.String key)
Method returns value of key in section

Parameters:
groupName - - name of section
key -
Returns:
value