Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

new line when using DataOutputStream, Android

Tags:

java

android

Im trying to export some data from my database to a file. I m using the DataOutputStream because I need the method writeChars(String r).

The problem is that I cannot find a way to change the line. the "\n" leaves a space but its not changing the line. Is there any way to do it?

like image 795
user1347280 Avatar asked Feb 19 '23 07:02

user1347280


1 Answers

If you just want to write text to a file you have chosen the wrong class. DataOuputStream.writeChars always writes characters in UTF-16BE. Use BufferedWriter or PrintWriter instead. PrintWriter.println appends a platform specific line separator to the end of the line. The line separator is defined by the system property line.separator, and is not necessarily a single newline character ('\n'). E.g for Windows "\r\n", for Unix '\n' etc.

like image 85
Evgeniy Dorofeev Avatar answered Mar 03 '23 13:03

Evgeniy Dorofeev