No one will write the method for you, but we can direct you to the correct place.
I'm not 100% sure, but I would say that you need to use a Byte Stream. Here is a brief tutorial that you should find...