JXTA

net.jxta.document
Class FileDocument

java.lang.Object
  extended by net.jxta.document.FileDocument
All Implemented Interfaces:
Document, DocumentStreamIO

public class FileDocument
extends Object
implements Document

This class presents a Document interface for a specific file on disk.


Constructor Summary
FileDocument(File file)
          Create a new File Document.
FileDocument(File file, MimeMediaType type)
          Create a new File Document.
 
Method Summary
 String getFileExtension()
          Returns the file extension type used by this Document.
 MimeMediaType getMimeType()
          Returns the MIME Media type of this Document per IETF RFC 2046 MIME : Media Types.
 InputStream getStream()
          Returns the stream of bytes which represents the content of this Document.
 void sendToStream(OutputStream sink)
          Send the contents of this Document to the specified stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileDocument

public FileDocument(File file)
Create a new File Document.


FileDocument

public FileDocument(File file,
                    MimeMediaType type)
Create a new File Document.

Method Detail

getFileExtension

public String getFileExtension()
Returns the file extension type used by this Document. This value is usually chosen based upon the MIME Media Type.

Returns everything after the last '.' in the filename, or the empty string if the file name does not contain a '.'.

Specified by:
getFileExtension in interface Document
Returns:
An appropriate file extension for this Document.

getMimeType

public MimeMediaType getMimeType()
Returns the MIME Media type of this Document per IETF RFC 2046 MIME : Media Types.

JXTA does not currently support the 'Multipart' or 'Message' media types.

Specified by:
getMimeType in interface Document
Returns:
The MIME Media Type for this Document.

getStream

public InputStream getStream()
                      throws IOException
Returns the stream of bytes which represents the content of this Document.

Specified by:
getStream in interface DocumentStreamIO
Returns:
An InputStream containing the bytes of this Document.
Throws:
IOException - For errors while writing the Document.

sendToStream

public void sendToStream(OutputStream sink)
                  throws IOException
Send the contents of this Document to the specified stream.

Specified by:
sendToStream in interface DocumentStreamIO
Parameters:
sink - The OutputStream to which the Document will be written.
Throws:
IOException - For errors while writing the Document.

JXSE