Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2010
    Posts
    20
    Rep Power
    0

    Default writing ethernet data in to files

    Hello,
    I m very new to java.
    I want to write a java code to store ethernet data packets in a file.
    I would really appreciate if some one can help.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    Storing the data shouldn't be any problem.
    What format do you want it stored in?

  3. #3
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    java [language] on its own does not give you access to the low level ethernet frames. I would imagine you would need to use something like "jNetPcap", which is a java wrapper for the libpcap, a mature C library that does network and packet capture.

  4. #4
    Join Date
    Apr 2010
    Posts
    20
    Rep Power
    0

    Default

    Thank you for the reply.
    I want the data to be stored in hex.
    I just want to receive the data .
    I dont know much about java but can it be done using datagram socket in java?

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    I want the data to be stored in hex.
    Can you describe what you mean by hex.
    What do you want in each byte of the output file.
    Say you have an byte with decimal value 14. Do you want the byte to contain "E" or x0E.
    All data is ultimately describable in:
    binary, hex, octal, decimal.
    1110 = 0xE = 016 = 14

  6. #6
    Join Date
    Apr 2010
    Posts
    20
    Rep Power
    0

    Default ethernet data

    I want 0E .Any thing is fine.. as far as i can see the data.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    as far as i can see the data
    It would require a hex editor for you to see 0x0E in a byte.
    Or do you want a String of 2 characters: "0E"?

  8. #8
    Join Date
    Apr 2010
    Posts
    20
    Rep Power
    0

    Default

    string "0E" is fine

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    See the Integer class. It has methods to convert int values to Strings in different representations.

Similar Threads

  1. Reading/Writing files through Applet
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 03-09-2009, 11:45 AM
  2. Reading and Writing Text Files
    By kandt in forum New To Java
    Replies: 1
    Last Post: 11-12-2008, 03:15 AM
  3. Writing to files within jar files
    By erhart in forum Advanced Java
    Replies: 0
    Last Post: 02-04-2008, 02:50 AM
  4. Applets writing to files
    By bugger in forum New To Java
    Replies: 2
    Last Post: 11-20-2007, 08:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •