Java ini4j error reading file created by windows software

347 views Asked by At

I am trying to use the ini4j to get data from a windows software log file. The file looks like:

[Production]
Code=I-MS01-11002
Time=2012-01-25T15:58:50+02:00
RequestType=Process Order
OrderID=0183

When I try:

Wini ini = new Wini(fileList[i]);
System.out.println(ini.keySet());

The output is: [?, P r o d u c t i o n]

Please advise where I am going wrong.

1

There are 1 answers

0
Chris Shaw On BEST ANSWER

I have found the original file is saved in UTF16 format. A work around, that seems to work, but may not be the best way to do it:

InputStream is = new BufferedInputStream(new FileInputStream(fileList[i]));
Reader reader = new InputStreamReader(is, "UTF-16");
Ini ini = new Ini();
ini.load(reader);
System.out.println(ini.keySet());

The output is now: [Production]