|
abstract boolean | open (boolean forWriting) |
|
abstract boolean | write (byte[] buffer) |
|
abstract byte [] | read (int length) |
|
abstract boolean | close (boolean forWriting) |
|
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.open() , MuseFile.write() and MuseFile.close() functions are thread-safe.
§ close()
abstract boolean com.choosemuse.libmuse.MuseFile.close |
( |
boolean |
forWriting | ) |
|
|
abstract |
Closes opened file.
This method is called when MuseFileWriter or MuseFileReader is destroyed, or when close is called on either class.
- Parameters
-
forWriting | true if the file should be closed for writing. false if for reading. |
- Returns
true
if file is closed properly, false
otherwise.
§ open()
abstract boolean com.choosemuse.libmuse.MuseFile.open |
( |
boolean |
forWriting | ) |
|
|
abstract |
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.
- Parameters
-
forWriting | true if the file should be opened for writing. false if for reading. |
- Returns
true
when file is opened successfully, false
otherwise.
§ read()
abstract byte [] com.choosemuse.libmuse.MuseFile.read |
( |
int |
length | ) |
|
|
abstract |
Reads "length" bytes from file starting from current pointer position.
- Parameters
-
length | The number of bytes to read. |
- Returns
- 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 | ) |
|
|
abstract |
Writes buffer to file.
This method is called when you flush MuseFileWriter .
- Parameters
-
- Returns
true
when buffer is written to successfully, false
otherwise.
The documentation for this class was generated from the following file: