jicarilla-sandbox/platform/components/http/impl/src/java/org/jicarilla/http HTTPFileReaderImpl.java,NONE,1.1
| Newsgroups | gmane.comp.java.jicarilla.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/java/org/jicarilla/http
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14437/platform/components/http/impl/src/java/org/jicarilla/http
Added Files:
HTTPFileReaderImpl.java
Log Message:
move reader impl to proper location
--- NEW FILE: HTTPFileReaderImpl.java ---
package org.jicarilla.http;
import org.jicarilla.io.Filesystem;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
/**
*
*
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id: HTTPFileReaderImpl.java,v 1.1 2004/02/26 15:15:23 lsimons Exp $
*/
public class HTTPFileReaderImpl implements HTTPFileReader
{
public final static int BUFFER_SIZE = 8096;
private Filesystem m_filesystem;
public HTTPFileReaderImpl( Filesystem fs )
{
setFilesystem( fs );
}
public Filesystem getFilesystem()
{
return m_filesystem;
}
public void setFilesystem( Filesystem filesystem )
{
m_filesystem = filesystem;
}
public int readFile( String file, HTTPMessage res )
throws IOException
{
ReadableByteChannel rbc = getFilesystem().getFile( file );
int size = 0;
while(true)
{
ByteBuffer buf = ByteBuffer.allocate( BUFFER_SIZE );
int read = rbc.read( buf );
if( read < 0 )
break;
if( read == 0 )
continue;
size += read;
buf.rewind();
buf.limit(read);
res.addBodyPart(buf);
}
getFilesystem().returnFile( rbc );
return size;
}
}
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click