I am creating a text file and writing some data into it.the string i want to write in file is written successfully but whenever i want to write the new line (use ) in file it shows some boxes in that notpad file like[][]][]. How can i write the new line character in text file.tell me what i m doing wrong.Here is my code.Thanks in advance.
try {
//FileWriter f = new FileWriter("/sdcard/download/possible.txt");
FileOutputStream fOut = openFileOutput("report.txt",MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write("Diet Report"+"
");
osw.append("
Food Calories Consumed
");
osw.append(""+SummaryReportActivity.map.keySet());
osw.append(""+SummaryReportActivity.map.values());
osw.append("
");
osw.append("
Exercise Calories Burnt
");
osw.append(""+SummaryReportActivity.exercisemap.keySet());
osw.append(""+SummaryReportActivity.exercisemap.values());
osw.append("
");
osw.append("
Weight Recorded
");
osw.append(""+SummaryReportActivity.weightmap.keySet());
osw.append(""+SummaryReportActivity.weightmap.values());
osw.append("
");
osw.append("
Net Calories Daily
");
osw.append(""+SummaryReportActivity.netCalorie.keySet());
osw.append(""+SummaryReportActivity.netCalorie.values());
osw.flush();
osw.close();
FileInputStream fIn = openFileInput("report.txt");
InputStreamReader isr = new InputStreamReader(fIn);
char[] inputBuffer = new char[100];
isr.read(inputBuffer);
readString = new String(inputBuffer);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//code to mail that text file as an attachement
Intent i=new Intent(Intent.ACTION_SEND);
//i.putExtra(Intent.EXTRA_EMAIL,emailaddress.getText().toString());
i.putExtra(Intent.EXTRA_SUBJECT, "Summary report of your diet");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("report.txt"));
i.setType("text/plain");
startActivity(i);