Nathan Campos
Nathan Campos

Reputation: 29507

List Properties and Convert to String[]

Is there any way to get a list of properties name from Properties and convert it into a String[]?

Upvotes: 2

Views: 2136

Answers (1)

BalusC
BalusC

Reputation: 1109362

Properties implements Map which has a keySet() method which returns a Set with all keys. The Set in turn has a toArray() method which allows you to get the values as a plain array.

So, this should do:

String[] keys = properties.keySet().toArray(new String[0]);

Upvotes: 8

Related Questions