Skip to content

Instantly share code, notes, and snippets.

@jozsef-vesza
Created April 21, 2014 10:33
Show Gist options
  • Save jozsef-vesza/11138874 to your computer and use it in GitHub Desktop.
Save jozsef-vesza/11138874 to your computer and use it in GitHub Desktop.
String returnString = "mystring";
Writer writer = new QRCodeWriter();
BitMatrix encoded = null;
try
{
encoded = writer.encode(returnString, BarcodeFormat.QR_CODE, 300, 300);
}
catch (WriterException ex)
{
Logger.getLogger(QRService.class.getName()).log(Level.SEVERE, null, ex);
}
ByteArrayOutputStream outs = new ByteArrayOutputStream();
MatrixToImageWriter.writeToStream(encoded, "PNG", outs);
resp.setContentType("image/png");
resp.getOutputStream().write(outs.toByteArray());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment