• Post Reply Bookmark Topic Watch Topic
  • New Topic

Please help...... urgent

 
Huang Qingyan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!