Java PropertyResourceBundle(Reader reader) Constructor

Syntax

PropertyResourceBundle(Reader reader) constructor from PropertyResourceBundle has the following syntax.

public PropertyResourceBundle(Reader reader)      throws IOException

Example

In the following code shows how to use PropertyResourceBundle.PropertyResourceBundle(Reader reader) constructor.


/*w ww .j ava 2  s .c  o m*/
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.Iterator;
import java.util.PropertyResourceBundle;
import java.util.Set;

public class Main extends PropertyResourceBundle {
  public Main(Reader reader) throws IOException {
    super(reader);
  }

  public static void main(String[] args) throws IOException {
    String fileContent = "s1=1\n" + "s2=Main\n"
        + "s3=Fri Jan 31 00:00:00 IST 3913";
    StringReader reader = new StringReader(fileContent);

    Main bundle = new Main(reader);

    Set keySet = bundle.handleKeySet();
    Iterator keys = keySet.iterator();
    while (keys.hasNext()) {
      System.out.println("Bundle key: " + keys.next());
    }

  }
}

The code above generates the following result.