Created
July 19, 2012 06:20
-
-
Save neophob/3141124 to your computer and use it in GitHub Desktop.
Stream node.js to struts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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