• Log in or sign up for an account here: https://www.sythe.org/login

Basic Java

Status
Not open for further replies.

MineMarkPT

Forum Addict
Joined
Jun 19, 2012
Sythe Gold
0
Messages
477
Age
33
Location
Portugal
Im looking to write a java program, well two really, which provide the ability to transfer files using UDP protocol. This is for a school project so don't go on about UDP not being safe blabla, i know that.

So far I've came up with code enough to transfer strings and java objects from the client to the sever without any problems, however I cannot seem to be able to write code for transfering files. This can be any type of file.

I know that I am supposed to get a File object and then convert it to a byte array, but thats all I know so far.

Can anyone give me a hand on this? I can provide the code I have so far.

BTW: All answers on chrome seem either fishy or out of proportion to what I want.
 
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
I've never done it before, but couldn't you theoretically just load the file into a byte array as you say, then receive the same array on the server? If that doesn't work, then just make an ArrayList of bytes instead and send that to the server. An ArrayList is an object in Java terms so that should send no problem.

Also, if you're willing to experiment, figure out how to send an array of integers or maybe even just one integer. A byte is essentially the same thing just up to 128 and as low as -128.
 
Status
Not open for further replies.
Runescape Gamblingrunescape gambling
Back
Top