aspose file tools*
The moose likes Servlets and the fly likes Send a whole file across Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Send a whole file across " Watch "Send a whole file across " New topic
Author

Send a whole file across

Huang Qingyan
Greenhorn

Joined: Jan 18, 2002
Posts: 23
Dear experts,
May I know how to send a whole file across to the other host. Normally what we did was to send a text file line by line or byte by byte. In my case here, I wanted to send a whole .exe file across.
Can you please kindly advise me on this.
Warmest regards,
Franco
Val Pecaoco
Ranch Hand

Joined: Dec 05, 2001
Posts: 156
Hi Huang,
I'm afraid you have to bear with that
It's because the transport language of computers and the Internet is in bits and bytes, and you can only read it bit by bit either serially or in parallel.
Maybe it's more of a question of speed and capacity. Of course, if you have a gigabit fiber optic connection, a 100-MB file will be transfered in a zippy, such that the time it took will barely be noticeable and it appears you have transfered the "whole" file in one swoop.
Ex Animo Java!
-- Val


"Knowledge is power, but enthusiasm is the key." -- Lavern Barn
Huang Qingyan
Greenhorn

Joined: Jan 18, 2002
Posts: 23
Dear expert,
What you mean is no matter what extension my file is, I can only use byte by byte or line by line. Here is an example:
-----------------------------------------------
Socket sock = new Socket("127.0.0.1", 15000);
FileOutputStream fs = new FileOutputStream("test.exe");
PrintWriter pw = new PrintWriter(sock.getOutputStream);
pw.println(fs);
pw.flush;
-----------------------------------------------
Can I do it inorder to send the whole file across? So the other side will receive the file line by line too.
Please kindly advise me.
Warmest regards,
Franco
arun mahajan
Ranch Hand

Joined: Dec 07, 2001
Posts: 305
If I am understanding your requirement properly Perhaps the better way of doing it is using ObjectInputStream and ObjectOutputStream as these can handle the searlized objects. This offer a facility of sending the file as an object.
For Reading

For Writing:-

Am I right? Perhaps JGurus can tell better...Any comment Please..
regards,
Arun
 
wood burning stoves
 
subject: Send a whole file across