DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Thread: Properties

  1. #1
    Join Date
    Oct 2004
    Posts
    151

    Question Properties

    Hi everyone,

    I have a question about the use of properties.

    You see usually if you wanted to add a property you would do this

    Code:
    Properties systemProperties = System.getProperties();
    systemProperties.setProperty("http.proxyHost", proxy);
    systemProperties.setProperty("http.proxyPort", port);
    But the thing is i have heard now that this property class may be deprecated soon and people are now encouraged to use the ResourceBundle.

    Here is the thing i am not very sure how to use the ResourceBundle class. I tried to yahoo but almost found no information on it. For example like the above code that i have, how does one convert that using the ResourceBundle class??

    Any help is greatly appreciated

    Thank You

    Yours Sincerely

    Richard West

  2. #2
    Join Date
    May 2005
    Location
    Denmark / Copenhagen
    Posts
    15
    Hi
    A way to use ResourceBoundle is to create a java property file (with the extension properties). In this file you can write the properties like:
    PropertyName = PropertyValue

    You can then access these property from your code like:
    // Key is the PropertyName
    public static String getDefaultProperty(String key){
    String prop = null;
    try{
    ResourceBundle resource = ResourceBundle.getBundle(NameOfThePROPERTYFILE_WithNoExtension);
    prop = resource.getString(key);
    }catch(MissingResourceException e){
    //missing prop
    }
    return prop; //prop is the PropertyValue
    }
    }

    Hope this will help you.

    Per Mikkelsen

Similar Threads

  1. Replies: 1
    Last Post: 03-15-2002, 12:22 PM
  2. Replies: 0
    Last Post: 02-12-2002, 06:04 AM
  3. Replies: 0
    Last Post: 02-08-2002, 06:25 PM
  4. Reading file properties
    By Millard Melnyk in forum VB Classic
    Replies: 6
    Last Post: 06-02-2000, 03:55 PM
  5. Reading file properties
    By Millard Melnyk in forum VB Classic
    Replies: 0
    Last Post: 06-02-2000, 12:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links