Results 1 to 6 of 6

Thread: Properties of .ini file

  1. #1
    Join Date
    Dec 2009
    Posts
    211

    Properties of .ini file

    Hello,
    I have a little problem with a file "preference.ini" in my application, which contains a line in a euro format. The only problem is the euro sign. That is I have a problem in the properties of .ini file. Here is my code.
    Code:
    String str = "preference.ini";
    Properties pro = new Properties();
    FileInputStream prefDef = new FileInputStream(new File(str));
    pro.load(prefDef);
    prefDef.close();
    Do you guys have an solution for this code, if there is one then let me know? Any one else had the problem with this.
    Last edited by Logan 2; 25-01-2010 at 01:45 PM.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Properties of .ini file

    Hello,
    This is normal method load (InputStream) uses the ISO encoding, which does not have the euro character. You have am using the unicode character EURO, or use a InputStreamReader () specifying the encoding of your file. Note that you can also use direct FileReader () who will use the default encoding system.
    Otherwise a few remarks:
    1) No accents in the names of variables
    2) You must use a try / finally to close the stream
    Hope the information helps you.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Properties of .ini file

    Hello,
    Check this code, it may help you and i agree with the above said.
    Code:
    String str = "preference.ini";
    Properties prefDefaut = new Properties();
    FileReader prefDef = new FileReader(new File(str));
    		try {
    			prefDefaut.load(prefDef);
    		} finally {
    			prefDef.close();
    		}
    If you have any more queries with this topic then do post back.

  4. #4
    Join Date
    Dec 2009
    Posts
    211

    Re: Properties of .ini file

    Hi,
    In fact, I just simplified my code to put only the commands used. My file is in UTF-8 (as the whole project). In the meantime, I replaced "formatEuros = #. # # €" by "formatEuros = #. # # \ U20AC, but I do not think it will work, though I do not have any idea about it, because I have never implemented it. I'll try with FileReader (), and will see if the program works well.

  5. #5
    Join Date
    May 2008
    Posts
    2,389

    Re: Properties of .ini file

    Hello,
    My file is in UTF-8 (as the whole project).
    In this case it should be read in UTF-8, which does not load (InputStream). have a look at the following statements.
    Reader prefDef = new InputStreamReader(new InputStream(sys), "UTF-8");
    Try the following method and then see if your code runs.

  6. #6
    Join Date
    Dec 2009
    Posts
    211

    Re: Properties of .ini file

    Hey
    I have replaced my code with the following part of the program.
    Code:
    String str = "preference.ini";
    Properties pro = new Properties();
    File f = new File(str);
    InputStreamReader prefDef = new InputStreamReader(new FileInputStream(f),"UTF-8");
    pro.load(prefDef);
    prefDef.close();

Similar Threads

  1. Eclipse and File Properties
    By Ash maker in forum Software Development
    Replies: 5
    Last Post: 08-03-2010, 09:39 AM
  2. Properties file in java
    By HardWeaR in forum Software Development
    Replies: 5
    Last Post: 23-02-2010, 01:54 AM
  3. Reading properties of a file
    By TechGate in forum Software Development
    Replies: 5
    Last Post: 14-02-2010, 05:46 AM
  4. Cannot View AVI file Properties
    By Balgovind in forum Windows Software
    Replies: 2
    Last Post: 25-05-2009, 12:48 PM
  5. Change properties of PDF/A file
    By !const in forum Windows Software
    Replies: 3
    Last Post: 04-05-2009, 02:32 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,564,478.17822 seconds with 17 queries