Friday, 10 March 2017

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


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

db.properties
Java Tutorial: Java properties [How to print the property list out to the specified print writer] 
PropertiesDemo.java
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;

/*
 * public void list(PrintWriter 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);

            PrintWriter writer = new PrintWriter(System.out);
            /*
             * print the list with a PrintWriter object
             */
            p.list(writer);

            /*
             * flush the stream
             */
            writer.flush();

        }

    }
}
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
  • 1 comment:

    1. Truly a very good article on how to handle the future technology. After reading your post,thanks for taking the time to discuss this, I feel happy about and I love learning more about this topic
      Manpower Consultancy in Bangalore
      Hr Consultancy in bangalore
      Recruitment Consultancy in Bangalore

      ReplyDelete

    Google+ Followers

    Google+ Badge