I am supposed to develop a simple SFTP.
Things were going fine until my ByteArrayOutputStream
(in this case, baos
) was not writing all of the
Your do/while
loop runs until end of stream but the peer is never closing the socket. The protocol seems to require keeping the socket open for further commands, so you will have to adjust this part of it to include a length-word prefix so you know how many bytes to copy.
The question isn't about ByteArrayOutputStream
not writing all your bytes, it is about blocking in is.read()
.