• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

java RMI: Sending a file

Desova

Limp Gawd
Joined
Jun 24, 2002
Messages
467
i'm trying to get rmi to send a file across the network, just using the rmi method call. though i still havent found a way i can store the file as a single object and pass it as a variable.

files wont be particularly big, 100k max

does anyone know how to do it?
 
Haven't worked with RMI so I wouldn't know a better way. But to put a file in a variable you should probably use a "java.io.ByteArrayOutputStream". Simply read the file you want to send and store it in one of those ByteArrayOutputStream. It will be a copy of the file as an array of bytes. You can then call it's "toByteArray()" method that will return the byte array and send that over RMI.

To reread the file on hte server, create a "java.io.ByteArrayInputStream" with that array and it will be as if you are reading from the file.

Hope it helps.
 
Back
Top