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.
You can't use this keyword like - props. Mukus Mukus 4, 2 2 gold badges 37 37 silver badges 54 54 bronze badges. ApplicationContext is available only in case of Spring application — joro. Then load it as: props. Since your properties file is not at the root of your project, you don't need the leading slash. I was getting the exception thrown in the first place without the leading slash.
It's still not working. You can use java. Tarun Jain Tarun Jain 1 1 silver badge 7 7 bronze badges. How to convert InputStream to File in java? Article Contributed By :. Easy Normal Medium Hard Expert. Writing code in comment? Please use ide.
Load Comments. What's New. Most popular in Java. More related articles in Java. Comparator Interface in Java with Examples System. Let's look at the following example program that reads data from a file and writes the same to another file using FIleReader and FileWriter classes. The perfect place for easy learning File Handling using Byte Stream In java, we can use a byte stream to handle files. FileInputStream - It is a built-in class in java that allows reading data from a file.
Sounds like a program design exercise to me : First, you need to write code that can handle persisting Java's Properties object to disk, and retrieving Properties from disk.
CodeBlind CodeBlind 4, 1 1 gold badge 22 22 silver badges 34 34 bronze badges. Robin Robin Abhishek Choudhary Abhishek Choudhary 7, 18 18 gold badges 65 65 silver badges bronze badges. Sign up or log in Sign up using Google.
Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta.
0コメント