Well I tried in a lot of ways to do that, but not always works.
If you have any idea about that and you have the secure and efective way to send files through socket I'll appreciate that.
This the code that I am using, it works well for the small files, but for the big ones don't work
Client
synchronized (Writing) {
try{
FileInputStream f=new FileInputStream(up);
byte bytesFile[]=new byte[f.available()];
f.read(bytesFile);
f.close();
Writing.writeUTF(up.getName());
Writing.flush();
Writing.write(bytesFile);
Writing.flush();
Server
File dir=new File(Command.substring(5));
File n=new File(dir,reading.readUTF());
FileOutputStream nn=new FileOutputStream(n);
do{
byte bytesFile[]=new byte[reading.available()];
nn.write(bytesFile);
nn.flush();
}while(reading.available()!=0);
nn.close();
Any suggestions?