This line is problem:

return buffer[];

Without going into your logic and purpose of this
here is method without errors that returns byte array - buffer:


public byte[] downloadFile(){