• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

loading properties file

 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Martin Vanyavchich
Ranch Hand
Posts: 241
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you retrieve the values? Could you please paste that piece of code?
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

 
Martin Vanyavchich
Ranch Hand
Posts: 241
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Martin Vanyavchich
Ranch Hand
Posts: 241
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic