more efficient MailboxIterator.head() in FileBasedMailbox
[org.ibex.mail.git] / src / org / ibex / mail / FileBasedMailbox.java
index 2a614d7..e13e22d 100644 (file)
@@ -180,22 +180,8 @@ public class FileBasedMailbox extends Mailbox.Default {
             else if (f.lastModified()==MAGIC_DATE) f.setLastModified(System.currentTimeMillis());
             // FIXME
         }
-        public Headers head() {
-            if (done()) return null;
-            FileInputStream fis = null;
-            try {
-                return new Headers.Original(new Stream(new FileInputStream(file())));
-            } catch (IOException e) { throw new MailException.IOException(e);
-            } finally { if (fis != null) try { fis.close(); } catch (Exception e) { /* DELIBERATE */ } }
-        }
-        public Message cur() {
-            FileInputStream fis = null;
-            try {
-                return Message.newMessage(new Fountain.File(file()));
-                //} catch (IOException e) { throw new MailException.IOException(e);
-            } catch (Message.Malformed e) { throw new MailException(e.getMessage());
-            } finally { if (fis != null) try { fis.close(); } catch (Exception e) { /* DELIBERATE */ } }
-        }
+        public Headers head() { return done() ? null : new Headers(new Fountain.File(file())); }
+        public Message cur() { return Message.newMessage(new Fountain.File(file())); }
     }
 
     public static class Servlet extends HttpServlet {