`URL url = new URL("https://api.sep.abc/stream/streamid/channelid?connectionTimeout=30"); HttpURLConnection http = (HttpURLConnection)url.openConnection(); http.setRequestMethod("POST"); http.setDoOutput(true); http.setRequestProperty("Content-Type", "application/json"); http.setRequestProperty("Accept", "application/x-ndjson"); http.setRequestProperty("Accept-Encoding", "gzip"); http.setRequestProperty("authorization", "{bearer token}");
String data = "{\n"next": "NGE0YjRhMTYtMTgyOC00ZTdjLTgwZTE"\n}";
byte[] out = data.getBytes(StandardCharsets.UTF_8);
OutputStream stream = http.getOutputStream(); stream.write(out); InputStream stream = http.getInputStream(); GZIPInputStream gz = new GZIPInputStream(stream); BufferedReader reader4 = new BufferedReader(new InputStreamReader(gz));
StringBuilder stringBuilder3 = new StringBuilder(); String line3;
Read the response from the server line by line
while ((line3 = reader4.readLine()) != null) { System.out.println(line3); }
`
I am trying to read a zipped streaming data from an api and while extracting, I am getting a json data but suddenly it runs into
java.io.EOFException: Unexpected end of ZLIB input stream error.
can anyone please let me know if anything is wrong here or how to resolve this error.