Sending files in java

imported_nautique

Senior member
Jul 14, 2004
346
0
0
Does java provide a way to send entire files as bytes at once or do you have to read each line and write each line individually?
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
You could have a look at PipedReader and PipedWriter. PipedInputStream and PipedOutputStream have a warning about deadlock safety but the Reader and Writer don't; I'm not sure why they'd be any different, but I guess they're safe.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
You can use FileInputStream to read a file in by bytes...

what do you mean by "send"?
 

bersl2

Golden Member
Aug 2, 2004
1,617
0
0
Keep reading bytes from the file until EOF. Send these bytes to the other computer.

And if you don't know how to extract bytes from a file, you haven't read the API closely enough; it's the most elementary operation for a Stream.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: Red and black
First, you learn JNI. Then you wrap a call to sendfile.
Wtf? So basically you're suggesting something that's more work to do, slower, less secure and less portable?