Meaningless Drivel is fun!*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Parse suncertify.properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Parse suncertify.properties" Watch "Parse suncertify.properties" New topic
Author

Parse suncertify.properties

Martin Wallgren
Greenhorn

Joined: Jan 24, 2008
Posts: 6
In my URLyBird assignment there is a requirement to have suncertify.properties in the current working directory.

How can I add current working directory to class path without breaking the assignment must about no other arguments than the ones specified are allowed?

Maybe there is an easy way of opening this file as a ResourceBundle even though it's not on the class path?

EDIT: no worries. Found the solution by my self. If anyone else have this question here's what I did.

URL[] url = new URL[] { new File(System.getProperty("user.dir")).toURL() }; // Current working directory

SUNCERTIFY_RESOURCE_BUNDLE = ResourceBundle.getBundle("suncertify", Locale.getDefault(), new URLClassLoader(url));
[ February 24, 2008: Message edited by: Martin Wallgren ]

SCJP 5.0 2007-11-21<br />SCJD (working on URLyBird 1.2.3)
Thomas Heiss
Greenhorn

Joined: Feb 20, 2008
Posts: 9
Dear Martin, dear valued rancher,

Why did you choose to implement reading the file suncertify.properties with the ResourceBundle classes?

Personally I am going for (or at least I want to) with java.util.Properties.

But what I did not find:
Java Util class to read key/value pairs per section.

So what I would like to have is three sections in suncertify.properties:
[SERVER]
SERVER.host (optional if RMI supports multi network homed servers)
SERVER.port
SERVER.dblocation

[CLIENTSERVER]
CLIENTSERVER.host
CLIENTSERVER.port

[STANDALONE]
STANDALONE.dblocation=

Properties seems to read all keys into ONE HashMap.
I would have to implement the filtering on SERVER/STANDALONE/CLIENTSERVER on my own (what a crap and this is not spec conform as java JDK classes will be preferred by SUN).

Ranchers: Is there any way to read the whole Props file per section in a Properties instance out of the box?

Best regards

Thomas


Technical J2EE Solution Consultant<br /> - Specialist for Middleware and Messaging solutions --<br />Certified SCJP 5.0, SCBCD 1.3, SCEA I (SCJD, SCEA II/III running)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Parse suncertify.properties
 
Similar Threads
Passed! 378/400
Intelligent Current Working Directory
Packing of suncertify.properties
Passed! 378/400
B&S: How to use suncertify.properties ?