mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-25 05:33:40 +00:00
buffer fix
This commit is contained in:
parent
43a28fc490
commit
aadb7172a9
|
|
@ -21,9 +21,17 @@ BufferedOutputStream::~BufferedOutputStream()
|
|||
//Flushes this buffered output stream. This forces any buffered output bytes to be written out to the underlying output stream.
|
||||
void BufferedOutputStream::flush()
|
||||
{
|
||||
stream->write( buf, 0, count );
|
||||
if (stream == NULL)
|
||||
{
|
||||
app.DebugPrintf("BufferedOutputStream::flush() called but underlying stream is NULL\n");
|
||||
return;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
if (count > 0)
|
||||
{
|
||||
stream->write( buf, 0, count );
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Closes this output stream and releases any system resources associated with the stream.
|
||||
|
|
@ -31,6 +39,11 @@ void BufferedOutputStream::flush()
|
|||
void BufferedOutputStream::close()
|
||||
{
|
||||
flush();
|
||||
if (stream == NULL)
|
||||
{
|
||||
app.DebugPrintf("BufferedOutputStream::close() called but underlying stream is NULL\n");
|
||||
return;
|
||||
}
|
||||
stream->close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,11 @@ void DataOutputStream::deleteChildStream()
|
|||
//b - the byte to be written.
|
||||
void DataOutputStream::write(unsigned int b)
|
||||
{
|
||||
if (stream == NULL)
|
||||
{
|
||||
app.DebugPrintf("DataOutputStream::write(unsigned int) called but underlying stream is NULL\n");
|
||||
return;
|
||||
}
|
||||
stream->write( b );
|
||||
// TODO 4J Stu - Exception handling?
|
||||
written++;
|
||||
|
|
@ -31,6 +36,11 @@ void DataOutputStream::write(unsigned int b)
|
|||
|
||||
void DataOutputStream::flush()
|
||||
{
|
||||
if (stream == NULL)
|
||||
{
|
||||
app.DebugPrintf("DataOutputStream::flush() called but underlying stream is NULL\n");
|
||||
return;
|
||||
}
|
||||
stream->flush();
|
||||
}
|
||||
|
||||
|
|
@ -51,6 +61,11 @@ void DataOutputStream::write(byteArray b)
|
|||
//len - the number of bytes to write.
|
||||
void DataOutputStream::write(byteArray b, unsigned int offset, unsigned int length)
|
||||
{
|
||||
if (stream == NULL)
|
||||
{
|
||||
app.DebugPrintf("DataOutputStream::write(byteArray,...) called but underlying stream is NULL\n");
|
||||
return;
|
||||
}
|
||||
stream->write(b, offset, length);
|
||||
// TODO 4J Stu - Some form of error checking?
|
||||
written += length;
|
||||
|
|
@ -60,6 +75,11 @@ void DataOutputStream::write(byteArray b, unsigned int offset, unsigned int leng
|
|||
//The close method of FilterOutputStream calls its flush method, and then calls the close method of its underlying output stream.
|
||||
void DataOutputStream::close()
|
||||
{
|
||||
if (stream == NULL)
|
||||
{
|
||||
app.DebugPrintf("DataOutputStream::close() called but underlying stream is NULL\n");
|
||||
return;
|
||||
}
|
||||
stream->close();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue