Results 1 to 1 of 1
Thread: Sending files over network
- 04-15-2011, 08:28 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 1
- Rep Power
- 0
Sending files over network
Hello. I have made a simple server in java that sends requested files to clients via http://<ip>/<filename>. It creates a new thread for each client. The problem is the speed is limited to 100kBps per thread. I searched a little bit and I think I know the problem:
I think the problem is because I write byte by byte and that is slow, I think I should use BufferedReader and Writer. And heres the problem: I dont know how to add those two. I tried a few things but I cant make it work. FileWriter just cant use client.getOutputStream() as parameter. Please, some help here. thanks.Java Code:FileInputStream input = null; DataOutputStream output = null; ... output = new DataOutputStream(client.getOutputStream()); //client = Socket ... input = new FileInputStream(requestedFile); ... int read; try { for(;;) { read = input.read(); if (read==-1) { break; } output.write(read); } } ... client.close();Last edited by TerraViper-5; 04-15-2011 at 08:30 PM.
Similar Threads
-
sending and recieving files
By rav in forum New To JavaReplies: 9Last Post: 07-26-2010, 04:34 PM -
sending object through network/socket
By skandalouz in forum NetworkingReplies: 1Last Post: 12-24-2009, 07:34 AM -
Sending a key over network
By cst in forum NetworkingReplies: 0Last Post: 11-04-2009, 01:19 PM -
sending file over network
By qwerty in forum NetworkingReplies: 6Last Post: 04-25-2009, 01:55 AM -
Sending .GIF files over the network
By nadia in forum NetworkingReplies: 8Last Post: 12-30-2008, 11:57 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks