diff --git a/src/com/fsck/k9/mail/internet/MimeHeader.java b/src/com/fsck/k9/mail/internet/MimeHeader.java index 1b260cf9f..6a2672a93 100644 --- a/src/com/fsck/k9/mail/internet/MimeHeader.java +++ b/src/com/fsck/k9/mail/internet/MimeHeader.java @@ -83,14 +83,7 @@ public class MimeHeader public String[] getHeader(String name) { - ArrayList values = new ArrayList(); - for (Field field : mFields) - { - if (field.name.equalsIgnoreCase(name)) - { - values.add(field.value); - } - } + ArrayList values = findHeaders(name); if (values.size() == 0) { return null; @@ -100,17 +93,27 @@ public class MimeHeader public void removeHeader(String name) { - ArrayList removeFields = new ArrayList(); - for (Field field : mFields) - { - if (field.name.equalsIgnoreCase(name)) - { - removeFields.add(field); - } - } + + ArrayList removeFields = findHeaders(name); mFields.removeAll(removeFields); } + private ArrayList findHeaders(String name) { + ArrayList values = new ArrayList(); + Iterator iter = mFields.iterator(); + while (iter.hasNext()) + { + Field field = iter.next(); + if (field.name.equalsIgnoreCase(name) ) + { + values.add(field.value); + } + } + + return values; + } + + public void writeTo(OutputStream out) throws IOException, MessagingException { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024);