I am trying to a stream bytes by byte to a embedded display. It worked for text and Image but when i share it with Video, video getting corrupted.
I run the class offline and find its working but when sending on HTTP if fails. Below is ServerSide and ClientSide code
byte[] b = readByte()// my function which return bytes of Data
ServletOutputStream stream = httpServletResponse.getOutputStream();
stream.flush();
stream.write(b);
stream.flush();
URL url = new URL("localhost" + fp);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect();
InputStream is = conn.getInputStream();
System.out.println("Connection Open");
int pos = 0;
byte[] b = new byte[buffLength];
while (pos != -1) {
pos = is.read(b, pos, b.length - pos);
}
write2File(b);
No responses yet.