class LicenseUtils {

    public static void grantLicense(Context context, Item item,
            String licenseText) throws SQLException, IOException,
            AuthorizeException
    {
        // Put together text to store
        // String licenseText = "License granted by " + eperson.getFullName()
        // + " (" + eperson.getEmail() + ") on "
        // + DCDate.getCurrent().toString() + " (GMT):\n\n" + license;

        // Store text as a bitstream
        byte[] licenseBytes = licenseText.getBytes("UTF-8");
        ByteArrayInputStream bais = new ByteArrayInputStream(licenseBytes);
        Bitstream b = itemService.createSingleBitstream(context, bais, item, "LICENSE");

        // Now set the format and name of the bitstream
        b.setName(context, "license.txt");
        b.setSource(context, "Written by org.dspace.content.LicenseUtils");

        // Find the License format
        BitstreamFormat bf = bitstreamFormat.findByShortDescription(context,
                "License");
        b.setFormat(bf);

        bitstreamService.update(context, b);
    }

}