• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Please help...... urgent

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
And then the flying monkeys attacked. My only defense was this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic