Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Properties of .ini file

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 25-01-2010
Member
 
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 12:45 PM.
Reply With Quote
  #2  
Old 25-01-2010
Member
 
Join Date: Apr 2008
Posts: 1,947
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.
Reply With Quote
  #3  
Old 25-01-2010
Member
 
Join Date: May 2008
Posts: 2,007
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.
Reply With Quote
  #4  
Old 25-01-2010
Member
 
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.
Reply With Quote
  #5  
Old 25-01-2010
Member
 
Join Date: May 2008
Posts: 2,383
Re: Properties of .ini file

Hello,
Quote:
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.
Quote:
Reader prefDef = new InputStreamReader(new InputStream(sys), "UTF-8");
Try the following method and then see if your code runs.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #6  
Old 25-01-2010
Member
 
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();
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Properties of .ini file"
Thread Thread Starter Forum Replies Last Post
Eclipse and File Properties Ash maker Software Development 5 08-03-2010 08:39 AM
Properties file in java HardWeaR Software Development 5 23-02-2010 12:54 AM
Reading properties of a file TechGate Software Development 5 14-02-2010 04:46 AM
Cannot View AVI file Properties Balgovind Windows Software 2 25-05-2009 12:48 PM
Change properties of PDF/A file !const Windows Software 3 04-05-2009 02:32 PM


All times are GMT +5.5. The time now is 09:40 AM.