Skip to content

Instantly share code, notes, and snippets.

@vijayakumar-psg587
Created January 11, 2019 05:57
Show Gist options
  • Save vijayakumar-psg587/1367a774777593cd912ab2c32e850219 to your computer and use it in GitHub Desktop.
Save vijayakumar-psg587/1367a774777593cd912ab2c32e850219 to your computer and use it in GitHub Desktop.
ByteArrayPrintWriter
/**
* IMplemented own Printer as the new wrapper
*
*/
public class ByteArrayPrinter {
private ByteArrayOutputStream baos = new ByteArrayOutputStream();
private PrintWriter pw = new PrintWriter(baos);
private ServletOutputStream sos = new ByteArrayServletStream(baos);
public PrintWriter getWriter() {
return pw;
}
public ServletOutputStream getStream() {
return sos;
}
byte[] toByteArray() {
return baos.toByteArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment