ByteArrayOutputStream bao = new ByteArrayOutputStream();
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(bao,
                ResourcesPlugin.getEncoding());
        Marshaller marshaller = new Marshaller(outputStreamWriter);
        marshaller.setEncoding("GB2312");
        Content content = new Content(); 
        //bean中很多属性,bean下还有对象这里就不在一一写入。
        Bean bean = new Bean();
        bean.setName("AAA");
        content.setBean(bean);
        try
        {
            marshaller.marshal(content);
        } catch (MarshalException e)
        {
            throw new IOException(e.getMessage());
        } catch (ValidationException e)
        {
            throw new IOException(e.getMessage());
        }
        ByteArrayInputStream bai = new ByteArrayInputStream(bao.toByteArray());
        outputStreamWriter.close();
        bao.close();