/***************************************
 *                                     *
 *  JBoss: The OpenSource J2EE WebOS   *
 *                                     *
 *  Distributable under LGPL license.  *
 *  See terms of license at gnu.org.   *
 *                                     *
 ***************************************/
package org.jboss.remoting.transport.socket;

/**
 * SocketUtil is a set of socket-based utilities
 *
 * @author <a href="mailto:jhaynie@vocalocity.net">Jeff Haynie</a>
 * @version $Revision: 1.1.4.1 $
 */
public class SocketUtil
{
    public static byte [] pad (int len, int total)
    {
        StringBuffer buf=new StringBuffer();
        String value = String.valueOf(len);
        int c = value.length();
        while(c<total)
        {
            buf.append("0");
            c++;
        }
        buf.append(len);
        return buf.toString().getBytes();
    }
    public static int len (byte buf[])
    {
        String len = new String(buf);
        if (len.trim().length()<=0) return 0;
        return Integer.parseInt(len);
    }
}
