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
  • 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
    Java Tutorial: Java properties [How to print the property list out to the specified output stream] 
    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
  • Monday, 6 March 2017

    Java Tutorial: Properties class in java [How to store key-value pairs in xml]


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

    PropertiesDemo.java
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.Properties;
    
    /*
     * public void storeToXML(OutputStream os, String
     *                              comment) throws IOException
     * 
     * Parameters: 
     * -----------
     * 
     * os - the output stream on which to emit the XML
     * document. 
     * 
     * comment - a description of the property list, 
     * or null if no comment is desired.
     */
    
    class PropertiesDemo
    {
    
        public static void main(String[] args) throws IOException
        {
            Properties p = new Properties();
            // add some properties
            p.put("name", "Dog");
            p.put("age", "2 years");
    
            try (FileOutputStream fos = new FileOutputStream("properties.xml"))
            {
                /*
                 * Emits an XML document representing all of the
                 * properties contained in this table.
                 */
                p.storeToXML(fos, "Animal properties");
                System.out.println("Xml file is created successfully..");
    
            }
    
        }
    }
    
    Output
    Xml file is created successfully..
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/PropertiesDemo_storeToXML_App.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/2010ece32ddd64329464f57cc3a56f059cb8f810/BasicJava/PropertiesDemo_storeToXML_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
  • Java Tutorial: Properties class in java[How to load key-value pairs from xml]


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

    PropertiesDemo.java
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.util.Enumeration;
    import java.util.Properties;
    
    /*
     * public void loadFromXML(InputStream in) throws
     *                      IOException, InvalidPropertiesFormatException
     * 
     * Parameters: 
     * -----------
     * 
     * in - the input stream from which to read the XML
     * document.
     */
    class PropertiesDemo
    {
    
        public static void main(String[] args) throws IOException
        {
            Properties p = new Properties();
    
            try (FileInputStream fis = new FileInputStream("properties.xml"))
            {
                /*
                 * Loads all of the properties represented by
                 * the XML document on the specified input
                 * stream into this properties table.
                 */
                p.loadFromXML(fis);
    
                Enumeration<?> enumeration = p.propertyNames();
    
                while (enumeration.hasMoreElements())
                {
                    String key = (String) enumeration.nextElement();
                    String value = p.getProperty(key);
    
                    System.out.println(key + " = " + value);
                }
    
            }
    
        }
    }
    
    Output
    Width = 15
    Height = 200
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/PropertiesDemo_loadFromXML_App.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/2010ece32ddd64329464f57cc3a56f059cb8f810/BasicJava/PropertiesDemo_loadFromXML_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
  • Java Tutorial: System class in java [How to modify the system property]


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

    Click the below Image to Enlarge
    Java Tutorial: System class in java [How to modify the system property] 
    PropertiesDemo.java
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.util.Properties;
    
    public class PropertiesDemo
    {
    
        public static void main(String[] args) throws IOException
        {
            /*
             * Set up new properties object from file
             * "myProperties.txt"
             */
            FileInputStream fis = new FileInputStream("myProperties.txt");
            /*
             * This statement initializes the new properties
             * object, p, with the current set of system
             * properties
             */
            Properties p = new Properties(System.getProperties());
            p.load(fis);
    
            /*
             * To modify the existing set of system properties,
             * use System.setProperties. This method takes a
             * Properties object that has been initialized to
             * contain the properties to be set. This method
             * replaces the entire set of system properties with
             * the new set represented by the Properties object.         * 
             */
            System.setProperties(p);
            // display new properties
            System.getProperties().list(System.out);
    
        }
    }
    
    Output
    -- listing properties --
    java.runtime.name=Java(TM) SE Runtime Environment
    sun.boot.library.path=C:\Java\jre1.8.0_111\bin
    java.vm.version=25.111-b14
    java.vm.vendor=Oracle Corporation
    java.vendor.url=http://java.oracle.com/
    path.separator=;
    java.vm.name=Java HotSpot(TM) 64-Bit Server VM
    file.encoding.pkg=sun.io
    user.script=
    user.country=US
    sun.java.launcher=SUN_STANDARD
    sun.os.patch.level=Service Pack 1
    java.vm.specification.name=Java Virtual Machine Specification
    user.dir=D:\eclipse\workspace\PropertiesDemo
    java.runtime.version=1.8.0_111-b14
    java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
    java.endorsed.dirs=C:\Java\jre1.8.0_111\lib\endorsed
    os.arch=amd64
    name=Peter
    java.io.tmpdir=C:\Users\Ramesh\AppData\Local\Temp\
    line.separator=
    
    java.vm.specification.vendor=Oracle Corporation
    user.variant=
    os.name=Windows 7
    sun.jnu.encoding=Cp1252
    java.library.path=C:\Java\jre1.8.0_111\bin;C:\Windows\S...
    email=peter@yahoo.com
    java.specification.name=Java Platform API Specification
    java.class.version=52.0
    sun.management.compiler=HotSpot 64-Bit Tiered Compilers
    os.version=6.1
    user.home=C:\Users\Ramesh
    user.timezone=
    java.awt.printerjob=sun.awt.windows.WPrinterJob
    file.encoding=Cp1252
    java.specification.version=1.8
    user.name=Ramesh
    java.class.path=D:\eclipse\workspace\PropertiesDemo\bin
    java.vm.specification.version=1.8
    sun.arch.data.model=64
    java.home=C:\Java\jre1.8.0_111
    sun.java.command=PropertiesDemo
    java.specification.vendor=Oracle Corporation
    user.language=en
    awt.toolkit=sun.awt.windows.WToolkit
    java.vm.info=mixed mode
    java.version=1.8.0_111
    java.ext.dirs=C:\Java\jre1.8.0_111\lib\ext;C:\Windo...
    sun.boot.class.path=C:\Java\jre1.8.0_111\lib\resources.ja...
    java.vendor=Oracle Corporation
    file.separator=\
    java.vendor.url.bug=http://bugreport.sun.com/bugreport/
    sun.cpu.endian=little
    sun.io.unicode.encoding=UnicodeLittle
    sun.desktop=windows
    sun.cpu.isalist=amd64
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/PropertiesDemo_system_modify_App.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/2010ece32ddd64329464f57cc3a56f059cb8f810/BasicJava/PropertiesDemo_system_modify_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
  • Tuesday, 28 February 2017

    Kids: Capital of all countries | Capital of countries | Countries and capitals_V11


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

    Click the below Image to Enlarge
    Kids: Capital of all countries | Capital of countries | Countries and capitals_V11 
    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
  • Kids: Capital of all countries | Capital of countries | Countries and capitals_V10


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

    Click the below Image to Enlarge
    Kids: Capital of all countries | Capital of countries | Countries and capitals_V10 
    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
  • Kids: Capital of all countries | Capital of countries | Countries and capitals_V7


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

    Click the below Image to Enlarge
    Kids: Capital of all countries | Capital of countries | Countries and capitals_V7 
    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
  • Java Tutorial: System class in java - Playlist

    Java Tutorial: System class in java [How to get the default value if Key is not present]


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

    PropertiesDemo.java
    /*
     * public static String getProperty(String key, String
     *                                               def)
     * 
     * Parameters: 
     * ----------
     * 
     * key - the name of the system property.  
     * def - a default value.
     */
    
    public class PropertiesDemo
    {
    
        public static void main(String[] args)
        {
            /*
             * Gets the system property indicated by the
             * specified key.if not present it will return
             * default value.
             */
            String value1 = System.getProperty("a.b", "hello");
            System.out.println("value1 = " + value1);
    
            
            String value2 = System.getProperty("os.name", "hello");
            System.out.println("value2 = " + value2);
            
        }
    }
    
    Output
    value1 = hello
    value2 = Windows 7
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/System_getProperty_default_App.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/fecc858ed896ce9bbf3cb92f5d438fc2de9eee22/BasicJava/System_getProperty_default_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
  • Java Tutorial: System class in java [How to get the system property indicated by the specified key]


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

    PropertiesDemo.java
    /*
     * public static String getProperty(String key)
     *
     * Parameters:
     * ----------
     *
     * key - the name of the system property.
     */
    
    public class PropertiesDemo
    {
    
        public static void main(String[] args)
        {
            /*
             * Gets the system property indicated by the
             * specified key.
             */
            String value = System.getProperty("os.name");
            System.out.println("value = " + value);
    
            String value1 = System.getProperty("a.b");
            System.out.println("value1 = " + value1);
    
        }
    }
    
    Output
    value = Windows 7
    value1 = null
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/System_getProperty_App.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/fecc858ed896ce9bbf3cb92f5d438fc2de9eee22/BasicJava/System_getProperty_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
  • Java Tutorial: Properties class in java [How to get all the system properties]


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

    Click the below Image to Enlarge
    Java Tutorial: Properties class in java [How to get all the system properties] 
    Java Tutorial: Properties class in java [How to get all the system properties] 
    PropertiesDemo.java
    import java.io.IOException;
    import java.util.Iterator;
    import java.util.Properties;
    import java.util.Set;
    
    class PropertiesDemo
    {
    
        public static void main(String[] args) throws IOException
        {
    
            /*
             * Returns the system properties
             */
            Properties p = System.getProperties();
    
            /*
             * Returns a set of keys in this property list where
             * the key and its corresponding value are strings,
             * including distinct keys in the default property
             * list if a key of the same name has not already
             * been found from the main properties list.
             */
            Set<String> set = p.stringPropertyNames();
    
            Iterator<String> itr = set.iterator();
    
            while (itr.hasNext())
            {
                String key = (String) itr.next();
                /*
                 * Gets the system property indicated by the
                 * specified key.
                 */
                String value = p.getProperty(key);
                System.out.println(key + " = " + value);
            }
    
        }
    }
    
    Output
    java.runtime.name = Java(TM) SE Runtime Environment
    sun.boot.library.path = C:\Java\jre1.8.0_111\bin
    java.vm.version = 25.111-b14
    java.vm.vendor = Oracle Corporation
    java.vendor.url = http://java.oracle.com/
    path.separator = ;
    java.vm.name = Java HotSpot(TM) 64-Bit Server VM
    file.encoding.pkg = sun.io
    user.script = 
    user.country = US
    sun.java.launcher = SUN_STANDARD
    sun.os.patch.level = Service Pack 1
    java.vm.specification.name = Java Virtual Machine Specification
    user.dir = D:\eclipse\workspace\PropertiesDemo
    java.runtime.version = 1.8.0_111-b14
    java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
    java.endorsed.dirs = C:\Java\jre1.8.0_111\lib\endorsed
    os.arch = amd64
    java.io.tmpdir = C:\Users\Ramesh\AppData\Local\Temp\
    line.separator = 
    
    java.vm.specification.vendor = Oracle Corporation
    user.variant = 
    os.name = Windows 7
    sun.jnu.encoding = Cp1252
    java.library.path = C:\Java\jre1.8.0_111\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Java/jre1.8.0_111/bin/server;C:/Java/jre1.8.0_111/bin;C:/Java/jre1.8.0_111/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Lenovo\Bluetooth Software\;C:\Program Files\Lenovo\Bluetooth Software\syswow64;C:\Program Files\OpenVPN\bin;C:\Java\jdk1.8.0_111\bin;C:\Program Files\TortoiseGit\bin;C:\Program Files\Git\cmd;C:\Program Files\TortoiseHg\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;D:\eclipse;;.
    java.specification.name = Java Platform API Specification
    java.class.version = 52.0
    sun.management.compiler = HotSpot 64-Bit Tiered Compilers
    os.version = 6.1
    user.home = C:\Users\Ramesh
    user.timezone = 
    java.awt.printerjob = sun.awt.windows.WPrinterJob
    file.encoding = Cp1252
    java.specification.version = 1.8
    user.name = Ramesh
    java.class.path = D:\eclipse\workspace\PropertiesDemo\bin
    java.vm.specification.version = 1.8
    sun.arch.data.model = 64
    java.home = C:\Java\jre1.8.0_111
    sun.java.command = PropertiesDemo
    java.specification.vendor = Oracle Corporation
    user.language = en
    awt.toolkit = sun.awt.windows.WToolkit
    java.vm.info = mixed mode
    java.version = 1.8.0_111
    java.ext.dirs = C:\Java\jre1.8.0_111\lib\ext;C:\Windows\Sun\Java\lib\ext
    sun.boot.class.path = C:\Java\jre1.8.0_111\lib\resources.jar;C:\Java\jre1.8.0_111\lib\rt.jar;C:\Java\jre1.8.0_111\lib\sunrsasign.jar;C:\Java\jre1.8.0_111\lib\jsse.jar;C:\Java\jre1.8.0_111\lib\jce.jar;C:\Java\jre1.8.0_111\lib\charsets.jar;C:\Java\jre1.8.0_111\lib\jfr.jar;C:\Java\jre1.8.0_111\classes
    java.vendor = Oracle Corporation
    file.separator = \
    java.vendor.url.bug = http://bugreport.sun.com/bugreport/
    sun.cpu.endian = little
    sun.io.unicode.encoding = UnicodeLittle
    sun.desktop = windows
    sun.cpu.isalist = amd64
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/PropertiesDemo_System_App.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/fecc858ed896ce9bbf3cb92f5d438fc2de9eee22/BasicJava/PropertiesDemo_System_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
  • Java Tutorial: Properties class in java [How to get the keys using stringPropertyNames method]


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

    db.properties
    Java Tutorial: Properties class in java [How to get the keys using stringPropertyNames method] 
    PropertiesDemo.java
    import java.io.FileReader;
    import java.io.IOException;
    import java.util.Iterator;
    import java.util.Properties;
    import java.util.Set;
    
    /*
     * public Set<String> stringPropertyNames()
     * 
     * Returns: 
     * --------
     * 
     * a set of keys in this property list where the key and
     * its corresponding value are strings, including the
     * keys in the default property list.
     */
    
    class PropertiesDemo
    {
    
        public static void main(String[] args) throws IOException
        {
            FileReader fileReader = null;
            try
            {
                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);
    
                /*
                 * Returns a set of keys in this property list
                 * where the key and its corresponding value are
                 * strings, including distinct keys in the
                 * default property list if a key of the same
                 * name has not already been found from the main
                 * properties list.
                 */
                Set<String> set = p.stringPropertyNames();
    
                Iterator<String> itr = set.iterator();
    
                while (itr.hasNext())
                {
                    String key = (String) itr.next();
                    String value = p.getProperty(key);
                    System.out.println("Key = " + key + " , Value = " + value);
                }
    
            }
            finally
            {
                if (fileReader != null)
                {
                    fileReader.close();
                }
            }
        }
    }
    
    Output
    Key = user , Value = root 
    Key = password , Value = oracle 
    
    
    Click the below link to download the code:
    https://sites.google.com/site/ramj2eev1/home/javabasics/PropertiesDemo_stringPropertyNames_App.zip?attredirects=0&d=1

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

    Bitbucket Link:
    https://bitbucket.org/ramram43210/java/src/fecc858ed896ce9bbf3cb92f5d438fc2de9eee22/BasicJava/PropertiesDemo_stringPropertyNames_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
  • Google+ Followers

    Google+ Badge