title: Android File to String
body: <p>I want to read out a file in Android and get the content as a string. Then I want to send it to a server. But for testing I just create a file on the device and put the content into it:</p>
  
  <pre><code>InputStream stream = getContentResolver().openInputStream(fileUri);
  BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
  
  File dir = new File (Environment.getExternalStorageDirectory() + "/Android/data/" + getPackageName());
  if(!dir.exists())
      dir.mkdirs();
  File file = new File(dir, "output."+format); // format is "txt", "png" or sth like that
  
  if(!file.exists())
      file.createNewFile();
  
  BufferedWriter writer = null;
  writer = new BufferedWriter(new FileWriter(file));
  
  String line = reader.readLine();
  
  while (line != null)
  {
      writer.write(line);
      line = reader.readLine();
      if(line != null)
          writer.write("\n");
  }
  writer.flush();
  writer.close();
  stream.close();
  </code></pre>
  
  <p>This works for txt files but when I for example try to copy a pdf file it is openable but just white.</p>
  
  <p>Can anyone help me?</p>
  
  <p>Thanks</p>