Java – Convert HashMap to/from Properties

In the post, we show how to convert Java HashMap to Properties and versus.

I. Convert Java HashMap to Properties

1. Use putAll()

-> Method signature:

Sample Code:

2. Manual Put() with for-loop

II. Convert Java Properties to HashMap

1. Use HashMap’s constructor

2. Use Java 8 Collectors

3. Manual Put() with for-loop

III. Full SourceCode

1. HashMap -> Properties

2. Properties -> HashMap
Program 1 – use HashMap’s constructor

Program 2 – others



By grokonez | March 4, 2018.


Related Posts


Got Something To Say:

Your email address will not be published. Required fields are marked *

*