将.eml文件作为属性文件读取时出现问题

时间:2011-08-18 06:42:26

标签: java key-value email-headers

我有一个.eml文件,因为我有一些键值对,如下所示

Received: by exchange.mail.com 
id <01CC537B.684C4154@exchange.mail.com>; Fri, 5 Aug 2011 19:54:38 +0530
Content-class: urn:content-classes:dsn
Subject: Undeliverable: Prudential mail
Date: Fri, 5 Aug 2011 19:54:38 +0530
MIME-Version: 1.0
Content-Type: multipart/report;
report-type=delivery-status;
boundary="----_=_NextPart_001_01CC537B.684C4154"
This is a multi-part message in MIME format.

当我试图获取密钥时,它考虑'id','This'也作为密钥,但我的要求是仅通过符号':'和'='

来获取键值

如何设置键值是我自己的分隔符......

(我使用java的额外信息代码如下......)

strMailPath = "E:\\BMT_work\\Sample.eml";
File f = new File(strMailPath);
Properties pro = new Properties();
FileInputStream in = new FileInputStream(f);
pro.load(in);
System.out.println("All key are given: " + pro.keySet());
System.out.println("All values are given: " + pro.values());
ArrayList al = new ArrayList(pro.keySet());
ArrayList al2 = new ArrayList(pro.values());
for (int i = 0; i < al.size(); i++) {
  System.out.println((i+1)+" "+al.get(i)+" = "+al2.get(i));
}

谢谢你。

1 个答案:

答案 0 :(得分:0)

制作您自己的java.util.Properties版本并重新实施private void load0 (LineReader lr)。请注意,':'和'='是硬编码的,您可以在该方法中更改它们。