aspose file tools*
The moose likes Java in General and the fly likes loading properties file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "loading properties file" Watch "loading properties file" New topic
Author

loading properties file

Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Hi all

I have a properties file with more then 1000+ key and values

but some time some keys and its values are not loading in to memory

for Example "34545_NameExit=Name already exist"

Please help me what can go wrong


-Chiru
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
How do you retrieve the values? Could you please paste that piece of code?


SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289


Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
How come you're using URL, are you accessing the file over the network? With the constructor that you're using, with the stream, the file must be encoded in ISO-8859-1, can you check if it is?
Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

the file must be encoded in ISO-8859-1, can you check if it is?


If this is the problem why only one key value pair is not loading ?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14272
    
  21

Chiranjeevi Kanthraj wrote:but some time some keys and its values are not loading in to memory

How do you know that? Do you get error messages? Do the same key-value pairs really not load sometimes, but correctly other times (that would be very strange)? Can you show us the code that you're using to lookup values?

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
I can't reproduce your error. I've tried long properties files, different encodings, ... I always get all keys, including '34545_NameExit' by using

Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 289

Jesper Young wrote:
How do you know that? Do you get error messages? Do the same key-value pairs really not load sometimes, but correctly other times (that would be very strange)? Can you show us the code that you're using to lookup values?


Ok if its duplicate key its should reproduce every time for the same key. but its not happening for same key
Mukesh Ranjan
Greenhorn

Joined: Jun 24, 2009
Posts: 22
why don't you try fileinputstream instead of URL and if you are using URL , which class you are using,

Below code also works, you can use that also where i have used FileInputStream class

try {
URL url = new URL("D://a.txt");
ResourceBundle b = new PropertyResourceBundle(url.openStream());
System.out.println(b.getString("34545_NameExit"));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: loading properties file