0

The requirement here is to read incoming mail and extracting the key/value from them. At present is there any frameworks that supports these?

For instance, I simply thought of the following incoming email format

Hello,

Name: James
date: 25/09/2012
AlexR
  • 114,158
  • 16
  • 130
  • 208
Njax3SmmM2x2a0Zf7Hpd
  • 1,354
  • 4
  • 22
  • 44

2 Answers2

1

Occasionally you can use java.util.Properties class:

Properties props = new Properties();
props.load(in);

where in is either input stream or reader.

I said "occasionally" because properties supports both = and : as a delimiter. On other case you can just read line-by-line and split each line as following: line.split(YOUR_DELIMITER).

AlexR
  • 114,158
  • 16
  • 130
  • 208
0

It wasn't clear whether the format of the key/value pairs was already decided, or whether you have flexibility to choose the format yourself.

If the key/value pairs are in the format of internet email headers, you could use the JavaMail InternetHeaders class.

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40
  • it's not a must that it has to be key value pair format. However from the incoming mail side we should be able to retrieve these key and value. Usually the customer is asked to send the email using this format.. – Njax3SmmM2x2a0Zf7Hpd Sep 19 '12 at 20:47
  • Well, then you can decide on whichever format you like the best, and JavaMail will give you the InputStream for you to parse it however you like. – Bill Shannon Sep 20 '12 at 00:15