View Single Post
  #1 (permalink)  
Old 06-05-2007, 02:41 AM
bbq bbq is offline
Senior Member
 
Join Date: Jun 2007
Posts: 134
bbq is on a distinguished road
send files through socket
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
Code:
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
Code:
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?

Last edited by bbq : 07-04-2007 at 08:47 AM.
Reply With Quote
Sponsored Links