1

Possible Duplicate:
Decode Base64 data in java

Hi, I have this php code which decodes the encoded bytearray in Base64 .I need to rewrite the code in servlet .I tried using some of the examples online but it didnt work .This is my php codephp code

Please suggest me an equivalent servlet code...thank u ....i tried out this but its not working can u plase tell me where i am going wrong

String imgstring = request.getParameter("image");
    byte[] stringBytes = imgstring.getBytes();
    byte[] img = null;
    try {
        img = Base64.decode(stringBytes );
        response.setContentType ("text/html;charset=utf-8");
        String FILENAME="test.jpg";
        DataOutputStream os = new DataOutputStream(new FileOutputStream(
                FILENAME));
            os.write(img);

    } catch (IOException e) {
         e.printStackTrace();
     }
Community
  • 1
  • 1
prade
  • 43
  • 5

0 Answers0