Basic Java

Discussion in 'Programming General' started by MineMarkPT, Nov 19, 2013.

Thread Status:
Not open for further replies.
Basic Java
  1. Unread #1 - Nov 19, 2013 at 9:16 PM
  2. MineMarkPT
    Joined:
    Jun 19, 2012
    Posts:
    477
    Referrals:
    0
    Sythe Gold:
    0

    MineMarkPT Forum Addict
    Banned

    Basic Java

    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.
     
  3. Unread #2 - Nov 22, 2013 at 2:46 PM
  4. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

    Basic Java

    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.
     
  5. Unread #3 - Nov 30, 2013 at 2:06 PM
  6. Kimiko
    Joined:
    Nov 30, 2013
    Posts:
    15
    Referrals:
    0
    Sythe Gold:
    0

    Kimiko Newcomer

    Basic Java

    Transferring a file would be the same as transferring binary data.
    Create a DataOutputStream object, and just call the write method.
     
  7. Unread #4 - Dec 12, 2013 at 3:47 PM
  8. MineMarkPT
    Joined:
    Jun 19, 2012
    Posts:
    477
    Referrals:
    0
    Sythe Gold:
    0

    MineMarkPT Forum Addict
    Banned

    Basic Java

    I've finished this now. Thanks anyway.
     
< Need programmers for new fighting style game | Help with coding >

Users viewing this thread
1 guest
Thread Status:
Not open for further replies.


 
 
Adblock breaks this site