Dgrampublic class Dgram extends Object
Methods Summary |
---|
public static java.net.DatagramPacket | toDatagram(java.lang.String s, java.net.InetAddress destIA, int destPort)
// Deprecated in Java 1.1, but it works:
byte[] buf = new byte[s.length() + 1];
s.getBytes(0, s.length(), buf, 0);
// The correct Java 1.1 approach, but it's
// Broken (it truncates the String):
// byte[] buf = s.getBytes();
return new DatagramPacket(buf, buf.length,
destIA, destPort);
| public static java.lang.String | toString(java.net.DatagramPacket p)
// The Java 1.0 approach:
// return new String(p.getData(),
// 0, 0, p.getLength());
// The Java 1.1 approach:
return
new String(p.getData(), 0, p.getLength());
|
|