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]
# 1

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

mkoryaka at 2007-7-12 17:53:18 > top of Java-index,Java Essentials,Java Programming...
# 2

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

ryshi1264a at 2007-7-12 17:53:18 > top of Java-index,Java Essentials,Java Programming...
# 3
> 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.
camickra at 2007-7-12 17:53:18 > top of Java-index,Java Essentials,Java Programming...
# 4

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

ryshi1264a at 2007-7-12 17:53:18 > top of Java-index,Java Essentials,Java Programming...
# 5

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.

j_shadinataa at 2007-7-12 17:53:18 > top of Java-index,Java Essentials,Java Programming...
# 6
> 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
camickra at 2007-7-12 17:53:18 > top of Java-index,Java Essentials,Java Programming...
# 7
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.
ryshi1264a at 2007-7-12 17:53:18 > top of Java-index,Java Essentials,Java Programming...
# 8
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
j_shadinataa at 2007-7-12 17:53:18 > top of Java-index,Java Essentials,Java Programming...
# 9

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");

ryshi1264a at 2007-7-12 17:53:18 > top of Java-index,Java Essentials,Java Programming...