CSDN博客

img whxbb

Get Post Data From Http Request

发表于2004/6/23 10:13:00  954人阅读

分类: java source snippets

/** author:whxbb */

public byte[] getPostData(HttpServletRequest request) throws Exception
    {
        ServletInputStream data = request.getInputStream();
        DataInputStream is = null;
        try
        {
            is = new DataInputStream(data);       

        ArrayList al = new ArrayList();
        while (true)
        {
                try
                {
                    byte t =is.readByte();
                    al.add(new Byte(t));
                }
                catch(EOFException e)
                {
                    break;
                }
            }
            byte[] buffer = new byte[al.size()];

            for(int i = 0; i < buffer.length; i++)
            {
                buffer[i] = ((Byte)al.get(i)).byteValue();
            }
            return buffer;
        }
        catch(Exception e)
        {
            throw e;
        }
        finally
        {
            if (is != null)
                is.close();
        }
    }

0 0

相关博文

我的热门文章

img
取 消
img