I don't understand why create byte array in loop and copy it.If I don't create array in loop, code won't work.please explain to me
ObjectOutputStream outt = new ObjectOutputStream(socket.getOutputStream());
InputStream f=new FileInputStream(path);
byte[] buffer=new byte[10000];
int n;
while ((n=f.read(buffer))>0)
{
byte[] tmpBuff = new byte[10000];
System.arraycopy(buffer, 0, tmpBuff, 0, n);
total_length += n;
outt.writeObject(new MyObject(tmpBuff));
}
f.close();