<p>I am creating an application in java which will be the part of an external application. My application contains a viewport which shows some polygons and stuff like that. The external application needs to get the image of the viewport in gif format. For that it calls a method in an interface (implemented by my application) and my application returns the image. The external application needs to store the image in database (or something related to it which I dont need to worry about).</p>

<p>My question is:- What should be the data container type of the image when my application send it to the external application? I mean what should be the return type of the method?
Currently my gif encoder class returns a byte array. Is there any other 'better' option?</p>

A byte array could be appropriate if you expect the GIFs to be small, but you might consider using an
```
OutputStream
```
so you can stream bits more efficiently.
Even if today you just return a fully-populated
```
ByteArrayOutputStream
```
, this would allow you to change your implementation in future without affecting cilent code.