title: Converting video to base64 gives "out of memory error"
body: <p>When I convert small videos, it does not give an error. But when I am converting bigger videos, it gives the error below.</p>
  
  <pre><code>FATAL EXCEPTION: main
  java.lang.OutOfMemoryError
  at android.util.Base64.encode(Base64.java:534)
  at android.util.Base64.encode(Base64.java:494)
  at android.util.Base64.encodeToString(Base64.java:456)
  at gcm.b4deploy.com.operations2.StartedTasksAdapter.videoToBase64(StartedTasksAdapter.java:402)
  at gcm.b4deploy.com.operations2.StartedTasksAdapter.access$200(StartedTasksAdapter.java:57)
  gcm.b4deploy.com.operations2.StartedTasksAdapter$2$1.fileSelected(StartedTasksAdapter.java:288)
  at gcm.b4deploy.com.operations2.FileChooser$1.onItemClick(FileChooser.java:57)
  at android.widget.AdapterView.performItemClick(AdapterView.java:298)
  at android.widget.AbsListView.performItemClick(AbsListView.java:1114)
  at android.widget.AbsListView$PerformClick.run(AbsListView.java:2937)
  at android.widget.AbsListView$1.run(AbsListView.java:3695)
  at android.os.Handler.handleCallback(Handler.java:615)
  at android.os.Handler.dispatchMessage(Handler.java:92)
  at android.os.Looper.loop(Looper.java:153)
  at android.app.ActivityThread.main(ActivityThread.java:5037)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>And following is my videoToBase64 method;</p>
  
  <pre><code>private String videoToBase64(File file) {
      String encodedString = null;
  
      InputStream inputStream = null;
      try {
          inputStream = new FileInputStream(file);
      } catch (Exception e) {
          // TODO: handle exception
      }
      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();
      **encodedString = Base64.encodeToString(bytes, Base64.DEFAULT);**//error is in this line
      Log.i("Strng", encodedString);
  
      return encodedString;
  }
  </code></pre>
  
  <p>I have read some questions about this which are saying that I should split video and encode part by part but I dont understand how to do it.</p>
  
  <p>And is there any idea about what is the bound size of video to be able to not to get this outOfMemoryError?
  Thanks in advance.</p>