Kylie Irwin Kylie Irwin - 1 month ago 6
Ini Question

Parsing error after '#' line in ini file

I have a locally stored

ini file
which I am trying to parse as follows:

Ini ini = new Ini(new File("path/to/file"));
System.out.println(ini.get("header", "key"));


But I keep getting a parse error exception message pointing to the line after the comment line of the ini file (#). This is what my ini file looks like:

File.ini


#Tue Oct 11 18:45:03 CST 2016
PVIDNO=PALMUS-00001
PVIDNo=SSI-1
Authentication=VALID
ModelNo=KD03816-B001
PALMUS-ID=73364
PV-ID=PALMUS-01




Answer

You can do the same with Properties:

 Properties p = new Properties();
 p.load(new FileInputStream("user.props"));
 System.out.println("user = " + p.getProperty("DBuser"));
 System.out.println("password = " + p.getProperty("DBpassword"));
 System.out.println("location = " + p.getProperty("DBlocation"));

where the .ini file is:

# this a comment
! this a comment too
DBuser=anonymous
DBpassword=&8djsx
DBlocation=bigone