LibMuse 6.0.3
com.choosemuse.libmuse.MuseFile Class Referenceabstract

Public Member Functions

abstract boolean open (boolean forWriting)
abstract boolean write (byte[] buffer)
abstract byte [] read (int length)
abstract boolean close (boolean forWriting)

Detailed Description

A File interface. Normally you will not need to use this class directly as you can get a MuseFileReader or MuseFileWriter using MuseFileFactory .
If you provide your own implementation of this class, you should provide a way to specify the path to the file you want to access in a platform specific way.

Threading: MuseFile is not thread safe by default, but MuseFileWriter provides the necessary synchronization for its usage. If you are using MuseFile outside of that context, make sure the calls to the , MuseFile.write() and MuseFile.close() functions are thread-safe.

Member Function Documentation

§ close()

abstract boolean com.choosemuse.libmuse.MuseFile.close ( boolean  forWriting)

Closes opened file.
This method is called when MuseFileWriter or MuseFileReader is destroyed, or when close is called on either class.

forWritingtrue if the file should be closed for writing. false if for reading.
true if file is closed properly, false otherwise.

§ open()

abstract boolean ( boolean  forWriting)

Opens/creates the file. You can open same file for both writing and reading if you really (!) have to do so. Provide synchronization in this case. This method is called automatically when MuseFileWriter or MuseFileReader is created.

forWritingtrue if the file should be opened for writing. false if for reading.
true when file is opened successfully, false otherwise.

§ read()

abstract byte [] ( int  length)

Reads "length" bytes from file starting from current pointer position.

lengthThe number of bytes to read.
A byte array containing the data read. An empty buffer is returned if the file is empty or if the end of file was reached.

§ write()

abstract boolean com.choosemuse.libmuse.MuseFile.write ( byte []  buffer)

Writes buffer to file.
This method is called when you flush MuseFileWriter .

bufferThe data to write.
true when buffer is written to successfully, false otherwise.

The documentation for this class was generated from the following file: