Read properties file java only once




















With your subscription - you'll gain access to our exclusive IT community of thousands of IT pros. We can't always guarantee that the perfect solution to your specific problem will be waiting for you. If you ask your own question - our Certified Experts will team up with you to help you get the answers you need. Who are the certified experts? How quickly will I get my solution? We can't guarantee quick solutions - Experts Exchange isn't a help desk.

We're a community of IT professionals committed to sharing knowledge. Our experts volunteer their time to help other people in the technology industry learn and succeed. Plans and Pricing. This is the same text content which I have put into file and reading in above file.

Make sure you change file path if you are running above program in Windows environment. If you liked this article, then please share it on social media. Still have any questions about an article, leave us a comment. Signup for news, latest articles and special offers!! Additional menu. File ;. FileInputStream ;. IOException ;. You need something like the following:.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Reading Properties file in Java Ask Question. Asked 10 years, 1 month ago. Active 8 months ago. Viewed k times. Specifically: Exception in thread "main" java.

NullPointerException at java. Improve this question. Jesper k 44 44 gold badges silver badges bronze badges. Add a comment. Active Oldest Votes. Improve this answer. Mark Elliot Mark Elliot 71k 19 19 gold badges silver badges bronze badges. I did what you advised me but it still throws the same exception — nikos. Steven Gomez Steven Gomez 5 5 silver badges 2 2 bronze badges.

Don't forget to close the Reader in prop. There are many methods in that link. Why did you choose the one with class loader? Are there any advantages or disadvantages of that method? You can use ResourceBundle class to read the properties file. Paul Vargas This approach is recommended for i18n. My use case is for Jenkins so it's nice to have a solution that doesn't rely upon a bunch of ClassPathLoader shenanigans.



0コメント

  • 1000 / 1000