how to access the content of a properties
let's say that the properties file ("example.properties") contain the ff: fields..
emailadd=123@yahoo.com.xyz@gmail.com
user=ryan,shiela,joaquin
how will I be able to get the values of the emailadd in "example.properties" and put the corresponding values of emailadd
}catch (Exception e){
Mail mail =new Mail;
message = ex.getMessage
String[ ] recipient ={"emailadd"};
mail.post(recipient,"Error!",message,abc@hotmail.com);
[702 byte] By [
ryshi1264a] at [2007-11-27 6:29:17]

like this
File file = new File("example.properties");
Properties properties= new Properties();
properties.load(new FileInputStream(file));
String emailadd = properties.get("emailadd", "defualtValue");
//do something with emailadd here
dude here's the modification that i've done but I can't still access the content of the properties...
Mail mail = new Mail();
String message2 = sqlException.getMessage();
File file = new File("Add.properties");
Properties props = new Properties();
props.load(new FileInputStream(file));
String[] emailadd = {props.getProperty("emailadd","defaultValue")};
mail.postMail(emailadd,"An error has occurred, Auto-archive was unsuccessful.", message2,"lmnop@hotmail.com");
Message was edited by:
ryshi1264
> String[] emailadd = {props.getProperty("emailadd","defaultValue")};Where in the Properties API is an Array returned from a method? Learn to read the API.And where in the example your where given was an array used? Learn to follow the examples given.
i dont know man thats why i'm asking...the field emailadd needs to be in an array format for this statement to happen...
mail.postMail([b]emailadd[/b],"An error has occurred, Auto-archive was unsuccessful.", message2,"lmnop@urporntube.com");
i just need the values of emailladd which is in the "example.properties"
so that an error message will be sent.
Message was edited by:
ryshi1264
emailadd=123@yahoo.com.xyz@gmail.com
is not mean "123@yahoo.com"
& "xyz@gmain.com"
.
it's mean "123@yahoo.com.xyz@gmail.com". if you expect that were 2 email address, what is the separator char? "." (dot)? which dot? it's so ambigous.
> the field emailadd needs to be in an array format Well, then it seems to me like you have an array with one entry.So all you need to do is: a) create an arrayb) assign the value (from the Property file to the first entry of the array
besides form dot(.) are there any separators i can use..since my parameters are emaill add that include a dot...so that confusion can be avoided.
semicolon (;)?(Edit)even you change that dot to other unique character, what you get from calling properties.getProperty is single string. you need to seperate that your own.Message was edited by: j_shadinata
dude pare!!! got it na..check if this works fine....
Mail mail = new Mail();
String message2 = sqlException.getMessage();
File file = new File("C:/Documents and Settings/Administrator/Archive/src/Add.properties");
Properties props = new Properties();
props.load(new FileInputStream(file));
String tmp = props.get("emailadd").toString();
String[] recipient = tmp.split(",");
mail.postMail(recipient,"An error has occurred, Auto-archive was unsuccessful.", message2,"123@yehey.com");