tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Google Guava > Collections > Map from Properties

Map from Properties 

Google Guava is a java library with lot of utilities and reusable components. This requires the library guava-10.0.jar to be in classpath. The following example shows using Maps.fromProperties() API. It creates an immutable map instance from the given properties object.

File Name  :  
com/bethecoder/tutorials/guava/collection_tests/MapFromPropsTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.guava.collection_tests;

import java.util.Map;

import com.google.common.collect.Maps;

public class MapFromPropsTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    Map<String, String> sysProps = Maps.fromProperties(System.getProperties())
    System.out.println(sysProps);
  }
}
   

It gives the following output,
{java.runtime.name=Java(TM) SE Runtime Environment, 
sun.boot.library.path=C:\Program Files\Java\jdk1.6.0_10\jre\bin, 

....
....

os.name=Windows XP, 
sun.jnu.encoding=Cp1252,  
sun.desktop=windows}


                    Print

   



Books Recommendation

 
 
bl  br