• Post Reply Bookmark Topic Watch Topic
  • New Topic

Best way to file transfer a over sockets?  RSS feed

 
bharathi_babu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi jfolks, I am trying to transfer microsoft doc/excel/etc.. through sockets, I do this transfer byte by byte since I cannot afford to loose even a single byte. This approach seems to be very slow and a bottleneck
Can anyone can suggest me what stream would be the best way to transfer? I tried byte[] which was fast but not effective, and client has no handshake with server! it was hard to assume incoming byte[] size at the client side :roll:
I dont want RMI, due to heavy data transfer.
As always, thanks in advance.
 
Steve Deadsea
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try buffering the socket string in a BufferedInputStream on the recieving end and a BufferedOutputStream on the sending side. This will greatly enhance the performance by cutting down on calls to the operating system.
You can also do the buffering yourself by using a byte[]. You do not need to assume a length. When you read a byte it will tell you how much it has actualy read.
Reading from a network stream to a file, use the InputStream from the socket and a FileOutputStream:

Writing to a network stream from a file, use the OutputStream from the socket and a FileInputStream:
 
Nadeem Ahmad
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bharati
I m facing the problem in JSP
I want to read an Excel file from a HTML form
and then want upload tha data of Excel file into Orcale Table
can u help me
I hv posted this problem on the Forum
u can see by making a search on my name

Thanks in advance
Plzz give me the solution
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!