|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fu_berlin.ties.demo.SampleMails
public class SampleMails
This class manages a set of sample spam and nonspam mails. It is initialized
from a ZIP file containing the semple mails. The ZIP files must contain two
directories named spam
and nonspam
, all files
within these directories are supposed to be sample mails. All messaged are
supposed to use the default character set of the current platform.
Field Summary | |
---|---|
static String |
NO_SUBJECT
Subject generated if a message does not contain a "Subject:" header. |
Constructor Summary | |
---|---|
SampleMails(File sampleFile)
Creates a new instance. |
|
SampleMails(String sampleFileName)
Creates a new instance. |
Method Summary | |
---|---|
String |
getNonspam(int index)
Returns the contents of a ham message. |
String |
getSpam(int index)
Returns the contents of a spam message. |
int |
nonspamCount()
Returns the number of ham messages managed by this instance. |
String[] |
nonspamSubjects()
Lists the subjects of all ham mails. |
int |
spamCount()
Returns the number of spam messages managed by this instance. |
String[] |
spamSubjects()
Lists the subjects of all spam mails. |
String |
toString()
Returns a string representation of this object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String NO_SUBJECT
Constructor Detail |
---|
public SampleMails(File sampleFile) throws IOException
sampleFile
- a ZIP file containing the sample mails
IOException
- if the file cannot be read or is not a valid ZIP filepublic SampleMails(String sampleFileName) throws IOException
sampleFileName
- the name of a ZIP file containing the sample mails
IOException
- if the file cannot be read or is not a valid ZIP fileMethod Detail |
---|
public String getNonspam(int index) throws IndexOutOfBoundsException, IOException
index
- the index of the message to read
IndexOutOfBoundsException
- if index is out of range
(index < 0 || index >= nonspamCount()
)
IOException
- if an I/O error occurspublic String getSpam(int index) throws IndexOutOfBoundsException, IOException
index
- the index of the message to read
IndexOutOfBoundsException
- if index is out of range
(index < 0 || index >= spamCount()
)
IOException
- if an I/O error occurspublic int nonspamCount()
public String[] nonspamSubjects() throws IOException
nonspamCount()
containing the
subjects of all ham mails
IOException
- if an error occurs while reading from the ZIP filepublic int spamCount()
public String[] spamSubjects() throws IOException
spamCount()
containing the subjects
of all spam mails
IOException
- if an error occurs while reading from the ZIP filepublic String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |