• Post Reply Bookmark Topic Watch Topic
  • New Topic

Retrieving DatagramPacket data  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm attempting to grab a timestamp off an nist.gov server using the code below.

When I run this on Eclipse, I get the following back in the console.

Good news is, I'm connecting to the correct server and getting back a packet. However, I just can't seem to turn that packet's data into a comprehensible representation of that data. What am I missing?
 
Saloon Keeper
Posts: 4036
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Line 12 assumes two things: a) that the data returned is text, not binary, and b) if it is text, that it is encoded in the default encoding of your JVM. Both assumptions are shaky, unless you have further information about that server/service that says so.
 
Michael Peal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right, I went with this instead.



And got this output


So I now have something that makes more sense, I just have to convert that timestamp to a standard-format time and date.  That's a whole different matter, but at least this part seems to make sense now.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!