FileRegionDataSource

public class FileRegionDataSource extends FileDataSource

ByteBufferDataSource is an implementation of the javax.activation.DataSource that represents a data source of a region in the file. Creation Date: 2/11/2006

Author:Twinsen Tsang

Constructors

FileRegionDataSource

public FileRegionDataSource(File file, long position, long size)

Explicit Constructor.

Parameters:
  • file – The file associated to this datasource.
  • position – The start position of the region.
  • size – The size of the region.

FileRegionDataSource

public FileRegionDataSource(String filepath, long position, long size)

Explicit Constructor.

Parameters:
  • filepath – The file path associated to this datasource.
  • position – The start position of the region.
  • size – The size of the region

Methods

finalize

protected void finalize()

getByteBuffer

public ByteBuffer getByteBuffer()

This method will return an ByteBuffer representing the the data region and will throw an IOException if it can not do so or OutOfMemory error. For OutOfMemory error in direct memory usage, it’s still an issue in Java. http://bugs.sun.com/view_bug.do?bug_id=5025281 Properly reuse of the memory and set runtime parameter may solve the problem.

See also: java.nio.channels.FileChannel

getInputStream

public InputStream getInputStream()

This method will return an InputStream representing the the data and will throw an IOException if it can not do so. This method will return a new instance of ByteBufferInputStream with the direct byte buffer inside for each invocation.

See also: java.nio.channels.FileChannel, hk.hku.cecid.edi.sfrm.io.ByteBufferInputStream

getOutputStream

public OutputStream getOutputStream()

This method always throw IO exception.

Throws:
  • IOException – as output stream is not supported by this data source.

See also: javax.activation.DataSource.getOutputStream()