Friday, 10 March 2017

Java Tutorial: Java properties [How to print the property list out to the specified output stream]


Click here to watch in Youtube :
https://www.youtube.com/watch?v=YJsQppAzi9A&list=UUhwKlOVR041tngjerWxVccw

db.properties
user=root 
password=oracle 

PropertiesDemo.java
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

/*
 * public void list(PrintStream out)
 * 
 * Parameters:
 * ----------
 * 
 * out - an output stream.
 */
class PropertiesDemo
{

    public static void main(String[] args) throws IOException
    {

        try (FileReader fileReader = new FileReader("db.properties");)
        {

            Properties p = new Properties();
            /*
             * Reads a property list (key and element pairs)
             * from the input character stream in a simple
             * line-oriented format.
             */
            p.load(fileReader);

            /*
             * Prints this property list out to the
             * specified output stream.This method is useful
             * for debugging.
             */
            p.list(System.out);

        }

    }
}
Output
-- listing properties --
user=root 
password=oracle 

Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/PropertiesDemo_list_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/PropertiesDemo_list_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/2010ece32ddd64329464f57cc3a56f059cb8f810/BasicJava/PropertiesDemo_list_App/?at=master

See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • No comments:

    Post a Comment