public class MboxFile
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
READ_ONLY |
static java.lang.String |
READ_WRITE |
Constructor and Description |
---|
MboxFile(java.io.File file)
Constructor.
|
MboxFile(java.io.File file,
java.lang.String mode)
Constructor.
|
MboxFile(java.lang.String filepath)
Constructor.
|
MboxFile(java.lang.String filepath,
java.lang.String mode)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
long |
appendMessage(java.lang.CharSequence message)
Appends the specified message (represented by a CharSequence) to the
mbox file.
|
long |
appendMessage(MboxFile source,
int index)
Appends the specified message from another mbox file
|
long |
appendMessage(MboxFile source,
long srcpos,
int srcsize)
Appends the specified message from another mbox file
|
void |
close()
Close the mbox file and release any system resources.
|
java.lang.CharSequence |
getMessage(int index)
Returns a CharSequence 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.
|
java.io.InputStream |
getMessageAsStream(long begin,
int size)
Get message as stream
|
int |
getMessageCount()
Returns the total number of messages in the mbox file.
|
long |
getMessagePosition(int index)
Get byte offset position of a given message inside the mbox file
This method is slow when called for the first time, as it has to parse
the whole Mbox file for finding each message index.
|
long[] |
getMessagePositions()
Returns an initialised array of file positions
for all messages in the mbox file.
|
int |
getMessageSize(int index)
Get size of a message in bytes
|
java.io.InputStream |
getPartAsStream(long begin,
long offset,
int size) |
void |
purge(int[] messageNumbers)
Purge the specified messages from the file.
|
long |
size()
Return MBox file size in bytes
|
public static final java.lang.String READ_ONLY
public static final java.lang.String READ_WRITE
public MboxFile(java.io.File file) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public MboxFile(java.io.File file, java.lang.String mode) throws java.io.FileNotFoundException, java.io.IOException
file
- mode
- Either MboxFile.READ_ONLY or MboxFile.READ_WRITEjava.io.FileNotFoundException
java.io.IOException
public MboxFile(java.lang.String filepath)
filepath
- mode
- Either MboxFile.READ_ONLY or MboxFile.READ_WRITEpublic MboxFile(java.lang.String filepath, java.lang.String mode) throws java.io.FileNotFoundException, java.io.IOException
filepath
- mode
- Either MboxFile.READ_ONLY or MboxFile.READ_WRITEjava.io.FileNotFoundException
java.io.IOException
public long size() throws java.io.IOException
java.io.IOException
public long[] getMessagePositions() throws java.io.IOException
java.io.IOException
- thrown when unable to read
from the specified file channelpublic long getMessagePosition(int index) throws java.io.IOException, java.lang.ArrayIndexOutOfBoundsException
Get byte offset position of a given message inside the mbox file
This method is slow when called for the first time, as it has to parse the whole Mbox file for finding each message index.index
- Message Indexjava.io.IOException
java.lang.ArrayIndexOutOfBoundsException
public int getMessageSize(int index) throws java.io.IOException, java.lang.ArrayIndexOutOfBoundsException
index
- Message Indexjava.io.IOException
java.lang.ArrayIndexOutOfBoundsException
public int getMessageCount() throws java.io.IOException
java.io.IOException
public java.lang.CharSequence getMessage(int index) throws java.io.IOException
index
- the index of the message to retrievejava.io.IOException
public java.io.InputStream getMessageAsStream(long begin, int size) throws java.io.IOException
begin
- long Byte offset position for messagesize
- int Number of bytes to be readedjava.io.IOException
public java.io.InputStream getPartAsStream(long begin, long offset, int size) throws java.io.IOException
java.io.IOException
public java.io.InputStream getMessageAsStream(int index) throws java.io.IOException
index
- the index of the message to open
a stream tojava.io.IOException
public final long appendMessage(MboxFile source, long srcpos, int srcsize) throws java.io.IOException
source
- Source mbox filesrcpos
- Byte offset position of message at source mbox filesrcsize
- Size of source message in bytesjava.io.IOException
public final long appendMessage(MboxFile source, int index) throws java.io.IOException
source
- Source mbox fileindex
- Index of message to be appended at the source filejava.io.IOException
public final long appendMessage(java.lang.CharSequence message) throws java.io.IOException
message
- java.io.IOException
public void purge(int[] messageNumbers) throws java.io.IOException, java.lang.IllegalArgumentException
messageNumbers
- int[]java.io.IOException
java.lang.IllegalArgumentException
java.lang.ArrayIndexOutOfBoundsException
public void close() throws java.io.IOException
java.io.IOException