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

发布于 2024-11-30 02:15:34 字数 1236 浏览 2 评论 0原文

我有一个 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小女人ら 2024-12-07 02:15:34

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

Make your own version of java.util.Properties and re-implement private void load0 (LineReader lr). Note that ':' and '=' are hardcoded and you can changed them in that method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文