public static int [] getLanguages (Device dev)
    throws IOException
    {
	byte buf [] = null;

	try {
	    buf = getStandardDescriptor (dev,
		Descriptor.TYPE_STRING,
		(byte) 0, 0, 256);
	} catch (USBException e) {
	    // devices without strings stall here
	    if (!e.isStalled ())
		throw e;
	}
	if (buf == null || buf.length <4)
	    return null;

	int len = 0xff & buf [0];
	len >>= 1;
	len -= 1;
	if (len <= 0)
	    return null;

	int retval [] = new int [len];
	for (int i = 0; i < len; i++) {
	    int offset = 2 + (2 * i);
	    retval [i] = 0xff & buf [offset];
	    retval [i] += (0xff & buf [offset + 1]) << 8;
	}
	return retval;
    }