PropertyResourceBundle.getKeys() has the following syntax.
public Enumeration <String> getKeys()
In the following code shows how to use PropertyResourceBundle.getKeys() method.
//ww w .j a v a 2 s . com import java.io.InputStream; import java.io.StringBufferInputStream; import java.util.Enumeration; import java.util.PropertyResourceBundle; public class Main { public static void main(String[] args) throws Exception { // Prepare content for simulating property files String fileContent = "s1=1\n" + "s2=Main\n" + "s3=Fri Jan 31"; InputStream propStream = new StringBufferInputStream(fileContent); PropertyResourceBundle bundle = new PropertyResourceBundle(propStream); // Get resource keys Enumeration keys = bundle.getKeys(); while (keys.hasMoreElements()) { System.out.println("Bundle key: " + keys.nextElement()); } } }
The code above generates the following result.