Dear developers, Can you please kindly advise me on how to send a whole file across the network. For example, I create a socket between a server and client. I wanted to send a abc.exe file from server to client. I have try using BufferedReader's readLine() method to read the abc.exe file line by line and send them line by line. It has no problem sending and receiving but when I open the file at the other side, the file seems to be corrupt. My another question is how to write java codes to block certain port from coming into my PC or network. I think the concept is something like a Firewall. Can you please tell me the Java APIs for this issue? Warmest Regards, Franco
as for the first question you need to send the file using the Stream classes not the reader/writer ones cause you are dealing with raw bytes. use the BufferedInputStream abd BufferedOutputStream classes.