Byte Array to Stream

Is there a way to read a byte array using a Stream? Is there any subclass of Stream that do this?

Thanks.

Stream contains the method:

  size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer
  // terminates if length characters have been read or timeout (see setTimeout)
  // returns the number of characters placed in the buffer (0 means no valid data found)

MarkT:
Stream contains the method:

  size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer

// terminates if length characters have been read or timeout (see setTimeout)
  // returns the number of characters placed in the buffer (0 means no valid data found)

I want de the inverse. Like:

byte buffer[128];
MemoryStream stream(buffer);

byte b = stream.read();

....

I want de the inverse.

That's not what your post title or initial post says.

The Stream class derives from the print class which has both print() and write() methods that can take arrays. So, yes, a Stream class can write arrays.

I think what the PO wanted is a stream-like interface around a chunk of memory. For example, if we were to write a string to an array, we do

char buffer[100];
strcpy(buffer, "Hello world!");

If we wrap a stream interface around the array, it may look like the following.

MemoryStream stm(buffer);
stm.write("Hello world!");

It may seem redundant here, but it may be useful when some function takes a stream pointer as an argument, and in some cases we want that function to operate on a memory buffer.

I'd be interested to know if such a wrapper exists. If not, I think we can implement one using a simple queue structure on that array.