|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream com.sun.spot.flashmanagement.FlashFileOutputStream
public class FlashFileOutputStream
FlashFileOutputStream represents an output stream over some flash memory. There are two uses for this.
The first is to stream over the flash memory allocated to an instance of a FlashFile
.
In this case, you should construct the output stream accordingly, for example:
In this case, the output stream will throw an IOException if you attempt to write beyond the end of the last sector allocated to the FlashFile. Note that this will allow more than requiredSize bytes to be written to the file when requiredSize is not equal to a whole number of flash memory sectors.FlashFile myFile = new FlashFile("my file"); myFile.createNewFile(requiredSize); FlashFileOutputStream ffos = new FlashFileOutputStream(myFile);
In this case, the output stream will throw an IOException if you attempt to write beyond the end of the sector.FlashFileOutputStream ffos = new FlashFileOutputStream(new NorFlashSector(mySectorNumber));
Field Summary | |
---|---|
static int |
DEFAULT_BUFFER_SIZE
The default size of the output buffer. |
Constructor Summary | |
---|---|
FlashFileOutputStream(FlashFile file)
Construct an output stream over the space allocated to a previously created FlashFile |
|
FlashFileOutputStream(FlashFile file,
int bufferSize)
Construct an output stream over the space allocated to a previously created FlashFile, specifying a non-standard buffer size. |
|
FlashFileOutputStream(IAddressableNorFlashSector sector)
Construct an output stream over a sector of the flash memory. |
Method Summary | |
---|---|
void |
close()
Closes this output stream and releases any system resources associated with this stream. |
void |
flush()
Flushes this output stream and forces any buffered output bytes to be written out. |
void |
write(int b)
Writes the specified byte to this output stream. |
Methods inherited from class java.io.OutputStream |
---|
write, write |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_BUFFER_SIZE
Constructor Detail |
---|
public FlashFileOutputStream(FlashFile file) throws FlashFileNotFoundException
file
- The FlashFile to write data to
FlashFileNotFoundException
public FlashFileOutputStream(FlashFile file, int bufferSize) throws FlashFileNotFoundException
flush()
or close()
are called. Thus varying the buffer size affects the performance characteristics of the
output stream. The default value is 512;
file
- The FlashFile to write data tobufferSize
- The size - in bytes - for the FlashFile's output buffer.
FlashFileNotFoundException
public FlashFileOutputStream(IAddressableNorFlashSector sector) throws FlashFileNotFoundException
sector
- the sector to write data to.
FlashFileNotFoundException
Method Detail |
---|
public void write(int b) throws IOException
OutputStream
write
is that one byte is written
to the output stream. The byte to be written is the eight
low-order bits of the argument b
. The 24
high-order bits of b
are ignored.
Subclasses of OutputStream
must provide an
implementation for this method.
write
in class OutputStream
b
- the byte
.
IOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.OutputStream.write(int)
public void flush() throws IOException
OutputStream
flush
is
that calling it is an indication that, if any bytes previously
written have been buffered by the implementation of the output
stream, such bytes should immediately be written to their
intended destination.
The flush
method of OutputStream
does nothing.
flush
in class OutputStream
IOException
- if an I/O error occurs.OutputStream.flush()
public void close() throws IOException
OutputStream
close
is that it closes the output stream. A closed stream cannot perform
output operations and cannot be reopened.
The close
method of OutputStream
does nothing.
close
in class OutputStream
IOException
- if an I/O error occurs.OutputStream.close()
|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |