title: Apache Commons IO on Android
body: <p>I'm developing an Android application that uses <a href="http://commons.apache.org/proper/commons-io/download_io.cgi" rel="noreferrer">Apache Commons IO</a>, <strong>commons-io-2.4-bin.tar.gz</strong>.</p>
  
  <p>And I get some errors, one of them:</p>
  
  <pre><code>Could not find method java.lang.String.getBytes, referenced from method org.apache.commons.io.IOUtils.toInputStream
  </code></pre>
  
  <p>I think I don't have to worry about it, isn't it?</p>
  
  <p><strong>Is there another specific Android library that I can use instead of Apache Commons IO?</strong></p>
  
  <p>I'm using it here:</p>
  
  <pre><code>import java.io.IOException;
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.commons.io.IOUtils;
  import org.springframework.http.client.ClientHttpResponse;
  import org.springframework.web.client.DefaultResponseErrorHandler;
  import org.springframework.web.client.ResponseErrorHandler;
  
  import android.util.Log;
  
  public class CustomResponseErrorHandler implements ResponseErrorHandler
  {
  
      private ResponseErrorHandler errorHandler = new DefaultResponseErrorHandler();
  
      @Override
      public void handleError(ClientHttpResponse response) throws IOException
      {
          String theString = IOUtils.toString(response.getBody());
          Log.v("Error Handler", theString);
          CustomException exception = new CustomException();
          Map&lt;String, Object&gt; properties = new HashMap&lt;String, Object&gt;();
          properties.put("code", response.getStatusCode().toString());
          properties.put("body", theString);
          properties.put("header", response.getHeaders());
          exception.setProperties(properties);
  
          throw exception;
      }
  
      @Override
      public boolean hasError(ClientHttpResponse response) throws IOException
      {
          return errorHandler.hasError(response);
      }
  
  }
  </code></pre>
  
  <p>On this line:</p>
  
  <pre><code>String theString = IOUtils.toString(response.getBody());
  </code></pre>