I am reading a large XML file using HttpURLConnection in java, as shown below.
StringBuilder responseBuilder = new StringBuilder(1024); char[] buffer = new char[4096]; BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream)new DataInputStream(new GZIPInputStream(connection.getInputStream()))),"UTF-8")); int n = 0; while(n>=0){ n=br.read(buffer,0,buffer.length); if(n>0) responseBuilder.append(buffer,0,n); }
Is there a way to get the total number of bytes loaded into the BufferedReader before you finish reading char with char / line by line / char block with char.
source share