title: java.lang.RuntimeException: java.util.zip.DataFormatException: incorrect header check
body: <p>My target is to extract raw text from pdf file. I get the byte array but the content is encoded with <strong>FlateDecode</strong> algorithm. So I was trying  to decode the raw content using this code </p>
  
  <pre><code>public String readTextFile(Uri uri){
  
      String mSelectedFilePath = FileUtils.getPath(MainActivity.this,
              uri);
      Log.e(TAG," path "+mSelectedFilePath);
  
  
      File sdcard = Environment.getExternalStorageDirectory();
      StringBuilder text = new StringBuilder();
  
      try {
          File file = new File(mSelectedFilePath);
  
          try {
              BufferedReader br = new BufferedReader(new FileReader(file));
              String line;
  
              while ((line = br.readLine()) != null) {
                  Log.e(TAG," line "+line + " "+startStream+" "+startDecode);
                  byte[] pText;
                  if(line.contains("FlateDecode")){
                      startDecode = true;
  
                  }
                  if(line.equals("stream")){
                      startStream = true;
                      continue;
                  }
                  if(line.equals("endstream")){
                      startDecode = false;
                      startDecode = false;
                  }
  
                  if(startDecode &amp;&amp; startStream){
                      Log.e(TAG, " inside decode");
                      pText = FLATEDecode(line.getBytes());
                  }
                  else pText = line.getBytes();
                  String res = new String(pText,"UTF-8");
                  text.append(res);
                  text.append('\n');
                  Log.e(TAG,res);
              }
              br.close();
          }
          catch (IOException e) {
  
          }
      }catch (Exception e){
          e.printStackTrace();
      }
  
      return text.toString();
  </code></pre>
  
  <p>code for decoding : </p>
  
  <pre><code>    byte[] buf = new byte[1024];
  
      Inflater decompressor = new Inflater();
      decompressor.setInput(src);
  
      // Create an expandable byte array to hold the decompressed data
      ByteArrayOutputStream bos = new ByteArrayOutputStream(src.length);
  
      try {
          while (!decompressor.finished()) {
              int count = decompressor.inflate(buf);
              bos.write(buf, 0, count);
          }
      } catch (DataFormatException e) {
          decompressor.end();
          throw new RuntimeException(e);
      }
      decompressor.end();
  
      return bos.toByteArray();`
  </code></pre>
  
  <p>But I am getting this error </p>
  
  <pre><code>Caused by: java.util.zip.DataFormatException: incorrect header check
  java.util.zip.Inflater.inflateImpl(Native Method)
  java.util.zip.Inflater.inflate(Inflater.java:237)
  java.util.zip.Inflater.inflate(Inflater.java:214)
  </code></pre>
  
  <p>I know that I can use a library like <strong>itext</strong> or <strong>pdfbox</strong> , but the problem is these library doesn't work well with <strong>bangla</strong> pdf which is my final target. That's why I am trying to build a pdf content extractor from scratch. Here some the raw data  I get from pdf. I want to decode it to get the original data. </p>
  
  <pre><code>3 0 obj
  &lt;&lt;/Type/Page/Parent 2 0 R/Resources&lt;&lt;/Font&lt;&lt;/F1 5 0 R&gt;&gt;/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] &gt;&gt;/MediaBox[ 0 0 612 792] /Contents 4 0 R/Group&lt;&lt;/Type/Group/S/Transparency/CS/DeviceRGB&gt;&gt;/Tabs/S/StructParents 0&gt;&gt;
  endobj
  4 0 obj
  &lt;&lt;/Filter/FlateDecode/Length 126&gt;&gt;
  stream
  x�S�P����u�tQ0��SprqVp
  </code></pre>