on 11-25-2008 2:16 AM
hi all,
I have developed one webdynpro application. In this application i need to access mdm server to continue. For getting the connection i need to pass the IP addresses.
Can i have code how to read the properties file which is residing in the server file. with out included along with the application. keeping some where in the file structure in the server. I want to read that properties file by maintain the iP addresses and users in properties file based on the key i want to read like below.
servername="abcServer"
username="john"
password="test123"
Please send me the code how to read this properties file from the file structure and how to read this values by key in webdynpro application
Regards
Vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vijay,
You can try this piece of code too:
Properties props = new Properties();
//try retrieve data from file
//catch exception in case properties file does not exist
try {
props.load(new FileInputStream("c:\property\Test.properties")); //File location
String serverName = props.getProperty("servername"); //Similarly, you can access the other properties
if(serverName==null)
{
//....do appropriate handling
}
} catch(IOException e)
{
e.printStackTrace();
}
Regards,
Alka.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
vijay,
you can use Pavels' code if it is in same server. or if you want a file from server file system, go for [java.io.File|http://java.sun.com/j2se/1.3/docs/api/java/io/File.html].
if the file needs to be a part of application, put it in \src\package\mimes\ folder.
let me know if this is not what you looking for
nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello, Vijay Krishna Meda!
Please consider following code.
final String servername;
final String username;
final String password;
try {
final IWDConfiguration configuration =
WDConfiguration.getConfigurationByName(
wdComponentAPI.getDeployableObjectPart(),
"Connection"); // Name of configuration file without ".properties"
servername = configuration.getStringEntry("servername");
username = configuration.getStringEntry("username");
password = configuration.getStringEntry("password");
} catch (WDConfigurationNotFoundException e) {
// Configuration not found
} catch (WDInvalidConfigParameterException e) {
// Invalid parameter
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.