title: Convert a file (<100Mo) in Base64 on Android
body: <p>I am trying to convert a file from the sdcard to Base64 but it seems the file is too big and i get an OutOfMemoryError.</p>
  
  <p>Here is my code : </p>
  
  <pre><code>InputStream inputStream = null;//You can get an inputStream using any IO API
  inputStream = new FileInputStream(file.getAbsolutePath());
  byte[] bytes;
  byte[] buffer = new byte[8192];
  int bytesRead;
  ByteArrayOutputStream output = new ByteArrayOutputStream();
  try {
      while ((bytesRead = inputStream.read(buffer)) != -1) {
          output.write(buffer, 0, bytesRead);
      }
  } catch (IOException e) {
      e.printStackTrace();
  }
  bytes = output.toByteArray();
  attachedFile = Base64.encodeToString(bytes, Base64.DEFAULT);
  </code></pre>
  
  <p>Is there a way to go around the OutOfMemoryError while filing the String attachedFile ?</p>