1 17 18 package org.apache.james.core; 19 20 import java.io.IOException ; 21 import java.io.InputStream ; 22 23 30 public abstract class MimeMessageSource { 31 38 public abstract String getSourceId(); 39 40 48 public abstract InputStream getInputStream() throws IOException ; 49 50 57 public long getMessageSize() throws IOException { 58 int size = 0; 59 InputStream in = null; 60 try { 61 in = getInputStream(); 62 int read = 0; 63 byte[] data = new byte[1024]; 64 while ((read = in.read(data)) > 0) { 65 size += read; 66 } 67 } finally { 68 try { 69 if (in != null) { 70 in.close(); 71 } 72 } catch (IOException ioe) { 73 } 76 } 77 return size; 78 } 79 80 } 81 | Popular Tags |