|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.fortuna.mstor.data.MboxFile
public class MboxFile
Provides access to an mbox-formatted file. To read an mbox file using a non-standard file encoding you may specify the following system property:
-Dmstor.mbox.encoding=<some_encoding>
If no encoding system property is specified the default file encoding will be used.
$Id$ Created: [6/07/2004] Contributors: Paul Legato - fix for purge() method, Michael G. Kaiser - add/strip of ">" characters from message content matching "From_" pattern (appendMessage()/getMessage())
| Nested Class Summary | |
|---|---|
static class |
MboxFile.BufferStrategy
Strategy for I/O buffers. |
| Field Summary | |
|---|---|
static java.lang.String |
FROM__PREFIX
The prefix for all "From_" lines in an mbox file. |
static java.lang.String |
KEY_BUFFER_STRATEGY
A capability hint to indicate the preferred strategy for reading mbox files into a buffer. |
static java.lang.String |
READ_ONLY
Indicates a file should be opened for reading only. |
static java.lang.String |
READ_WRITE
Indicates a file should be opened for reading and writing. |
| Constructor Summary | |
|---|---|
MboxFile(java.io.File file)
|
|
MboxFile(java.io.File file,
java.lang.String mode)
|
|
| Method Summary | |
|---|---|
void |
appendMessage(byte[] message)
Appends the specified message (represented by a CharSequence) to the mbox file. |
void |
close()
Close the mbox file and release any system resources. |
byte[] |
getMessage(int index)
Convenience method that returns a message as a byte array containing the data for the message at the specified index. |
java.io.InputStream |
getMessageAsStream(int index)
Opens an input stream to the specified message data. |
int |
getMessageCount()
Returns the total number of messages in the mbox file. |
static boolean |
isValid(java.io.File file)
Indicates whether the specified file appears to be a valid mbox file. |
void |
purge(int[] msgnums)
Purge the specified messages from the file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String KEY_BUFFER_STRATEGY
public static final java.lang.String READ_ONLY
public static final java.lang.String READ_WRITE
public static final java.lang.String FROM__PREFIX
| Constructor Detail |
|---|
public MboxFile(java.io.File file)
throws java.io.FileNotFoundException
file - a reference to an mbox data file
java.io.FileNotFoundException - where the specified file doesn't exist
public MboxFile(java.io.File file,
java.lang.String mode)
file - a reference to an mbox data filemode - the mode used to open the file| Method Detail |
|---|
public final int getMessageCount()
throws java.io.IOException
java.io.IOException - where an error occurs reading messages
public final java.io.InputStream getMessageAsStream(int index)
throws java.io.IOException
index - the index of the message to open a stream to
java.io.IOException - where an error occurs reading the message
public final byte[] getMessage(int index)
throws java.io.IOException
index - the index of the message to retrieve
java.io.IOException - where an error occurs reading the message
public final void appendMessage(byte[] message)
throws java.io.IOException
message -
java.io.IOException - where an error occurs writing the message data
public final void purge(int[] msgnums)
throws java.io.IOException
msgnums - the indices of the messages to purge
java.io.IOException - where an error occurs updating the data file
public final void close()
throws java.io.IOException
java.io.IOException - where an error occurs closing the data filepublic static boolean isValid(java.io.File file)
file - an mbox file reference
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||