I use RMI and socket to transfer files between a client set. The problem is when running the code below sometimes i get this exception in client side :
FileNotFoundException
has two meanings:
For example if the filename you are sending contains a directory that doesn't exist at the server, you will get FileNotFoundException
from new FileOutputStream
.
There isn't enough (i.e. any) information in your question to say any more about that.
However:
You don't need object streams for this, or even data input/output streams. You're only using the basic read()
and write()
methods, so you may as well just use the socket streams directly.
You should use a larger buffer than 1024 bytes, say 8192 or a multiple thereof.
You can send multiple files per connection via the technique given in my answer to this question.