+ public static class Mailbox extends FileSystem {
+ String user;
+ private static Hashtable cache = new Hashtable();
+ public static Mailbox getForUser(String user) {
+ Mailbox ret = (Mailbox)cache.get(user);
+ if (ret == null) ret = new Mailbox(user);
+ return ret;
+ }
+ Mailbox(String user) { this.user = user; }
+ public FileSystem slash(String name) throws IOException {
+ throw new Error(this.getClass().getName() + " does not support the slash() method"); }
+ public synchronized int add(Message message) throws IOException {
+ FileOutputStream fos = new FileOutputStream("/var/mail/" + user, true);
+ PrintWriter pw = new PrintWriter(new OutputStreamWriter(fos));
+ pw.println("From " + message.envelopeFrom);
+ pw.flush();
+ message.dump(fos);
+ fos.close();
+ return -1;
+ }
+ }
+