FileDocCategorySizeDatePackage
Dgram.javaAPI DocExample3170Mon Apr 06 18:10:22 BST 1998None

Dgram

public class Dgram extends Object

Fields Summary
Constructors Summary
Methods Summary
public static java.net.DatagramPackettoDatagram(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.StringtoString(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());