org.nnsoft.shs.core.io
Class FileResponseBodyWriter

java.lang.Object
  extended by org.nnsoft.shs.core.io.FileResponseBodyWriter
All Implemented Interfaces:
ResponseBodyWriter

public final class FileResponseBodyWriter
extends Object
implements ResponseBodyWriter

Generates a body response from a File.


Constructor Summary
FileResponseBodyWriter(File toBeTransfered)
          Creates a new ResponseBodyWriter given the file has to be transferred to the body response.
 
Method Summary
 String contentType()
          Returns the mime type of the streamed response.
 long getContentLength()
          Returns the body content length if known, -1 otherwise.
 void write(WritableByteChannel target)
          Generates the body response into the target output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileResponseBodyWriter

public FileResponseBodyWriter(File toBeTransfered)
Creates a new ResponseBodyWriter given the file has to be transferred to the body response.

Parameters:
toBeTransfered - the file has to be transferred to the body response.
Method Detail

getContentLength

public long getContentLength()
Returns the body content length if known, -1 otherwise.

Specified by:
getContentLength in interface ResponseBodyWriter
Returns:
the body content length if known, -1 otherwise.

contentType

public String contentType()
Returns the mime type of the streamed response.

Specified by:
contentType in interface ResponseBodyWriter
Returns:
the mime type of the streamed response.

write

public void write(WritableByteChannel target)
           throws IOException
Generates the body response into the target output stream.

Specified by:
write in interface ResponseBodyWriter
Parameters:
target - the target output where body has to be generated
Throws:
IOException - is any error occurs during the body generation


Copyright © 2012 99 Software Foundation. All Rights Reserved.