Skip to content

Instantly share code, notes, and snippets.

@neophob
Created July 19, 2012 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neophob/3141124 to your computer and use it in GitHub Desktop.
Save neophob/3141124 to your computer and use it in GitHub Desktop.
Stream node.js to struts
protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
URL url = new URL("http://192.168.128.160:8001/grepper.htm");
HttpURLConnection httpcon = (HttpURLConnection) url.openConnection();
BufferedInputStream bis = new BufferedInputStream(httpcon.getInputStream());
ServletOutputStream out = response.getOutputStream();
log.debug("streamopen");
byte[] outputByte = new byte[4096];
int i=0;
//copy binary content to output stream
while ((i = bis.read(outputByte, 0, 4096)) != -1) {
log.debug("stream "+i+" bytes");
out.write(outputByte, 0, i);
}
httpcon.disconnect();
bis.close();
out.flush();
out.close();
return null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment