• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

loading properties file

 
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • 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
 
Ranch Hand
Posts: 241
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

 
Martin Vanyavchich
Ranch Hand
Posts: 241
  • 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
  • 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 ?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • 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
  • 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
  • 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
 
Greenhorn
Posts: 22
  • 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();
}
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic