I create a stream write to the file:

PrintStream stream = new PrintStream(openFileOutput("textFile",MODE_WORLD_READABLE)); 

Then I write down some hyphenated lines in this stream.

Then I read:

 FileInputStream stream = ctx.openFileInput("textFile"); InputStreamReader reader = new InputStreamReader(stream,"UTF-8"); while (reader.ready()){ int simb = reader.read(); outString = outString.concat(Character.toString((char)simb)); } 

Then I prepare the form for sending by mail:

 Intent mail = new Intent(Intent.ACTION_SEND_MULTIPLE); mail.setType("plain/text"); mail.putExtra(Intent.EXTRA_EMAIL, new String[] {"23433423@rambler.ru"}); mail.putExtra(Intent.EXTRA_SUBJECT, "письмо"); mail.putExtra(Intent.EXTRA_TEXT, outString); 

The problem is that in the postal form all the text in one line. If you open the recorded file "textFile" in AkelPad transfers there. Tell me how to fix it?

    1 answer 1

    Read the file line by line and manually add the transfer to the end of each line:

     FileInputStream stream = ctx.openFileInput("textFile"); BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8")); StringBuilder sb = new StringBuilder(); String inputLine; while ((inputLine = reader.readLine()) != null) { sb.append(inputLine); sb.append('\n'); } outString = sb.toString(); 
    • The class InputStreamReader has no method readLine () - alex
    • Really. Corrected the answer. - eugeneek
    • The problem was not with the code. And with the default mail client. I tried to send via VKontakte. Everything compiled fine. That is, to be sure that the user does not use the same flawed client is not. This is sad. - alex