Mads Nielsen wrote:I want to put the content of the file into a variable or array, so i can transfer the file over a socket.
I think I should mention that you don't actually need to put the contents of the file into memory to transfer it over a socket. In fact I'm surprised you suggest that, given that you posted some code which works. Just change the part which writes to a FileOutputStream to write to the socket's output stream instead.
(And get rid of the DataInputStream, you don't need it and it just serves to confuse the reader.)