|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpeer2me.message.FileObject
peer2me.message.SendFileObject
public class SendFileObject
This class extends FileObject
and implements Runnable
and is used by the
Message
class. When a file is attached to a Message that is to be sent, a
MessagePart
with this SendFileObject class is added to the Message.
This class is capable of reading a file from the filesystem in chunks.
Constructor Summary | |
---|---|
SendFileObject(java.lang.String fullPathToFile)
Constructor that starts a thread when called. |
Method Summary | |
---|---|
long |
getBytesLeft()
Returns the number of bytes that has not be read from the file yet |
int |
getNumberOfBytesJustRead()
Returns how many bytes was read during the last call to read() |
int |
numberOfChunksNeeded()
Calculates and returns how many chunks the file must be read in. |
byte[] |
read()
Reads a chunk of a file and returns the data in an array. |
void |
run()
Retrives information about the size of the file and sets private variables. |
Methods inherited from class peer2me.message.FileObject |
---|
getFileName, getFileSize, getFullPathToFile, isAccessGranted |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SendFileObject(java.lang.String fullPathToFile)
fullPathToFile
- The full path to the fileMethod Detail |
---|
public void run()
run
in interface java.lang.Runnable
public byte[] read()
chunkSize
. This method continues to read from the file form where it last
stopped. If the end of the file is reached, the fileconnection and
fileinputstream is closed and the last bytes are returned.
chunkSize
public int numberOfChunksNeeded()
20
, the method read()
must be called 20 times before the
entire file has been read.
read()
method must be called before the entire file has been readpublic long getBytesLeft()
public int getNumberOfBytesJustRead()
read()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |