将 .eml 文件读取为属性文件时出现问题
我有一个 .eml 文件,因为当我尝试获取键时,我有一些键值对,如下所示
Received: by exchange.mail.com
id <[email protected]>; 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));
}
谢谢adv。
I have a .eml file , in that i have some key value pairs like below
Received: by exchange.mail.com
id <[email protected]>; 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.
when im trying to get keys , its considering 'id', 'This' also as keys, but my requirement is to get the key-values only by symbols ':' and '='
how can i set the key-value's my own separator...
(Extra information I am using java the code is as follows....)
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));
}
thanks in adv.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建您自己的
java.util.Properties
版本并重新实现private void load0 (LineReader lr)
。请注意,“:”和“=”是硬编码的,您可以在该方法中更改它们。Make your own version of
java.util.Properties
and re-implementprivate void load0 (LineReader lr)
. Note that ':' and '=' are hardcoded and you can changed them in that method.