Java Collection How to - List Properties to a print stream or print writer








Question

We would like to know how to list Properties to a print stream or print writer.

Answer

import java.io.FileInputStream;
import java.util.Properties;
/*from  ww w .  ja  va2s. com*/
public class MainClass {
  public static void main(String args[]) throws Exception {
    Properties p = new Properties();
    p.load(new FileInputStream("test.txt"));
    p.list(System.out);
  }
}

The code above generates the following result.

The code above generates the following result.