java - How to handle new line character while creating csv file in android -
I'm making a CSV file in Android. The file is being successfully created but if the content has a new line character then the content formatting is upset. Please suggest how to handle the new line character.
If additional information can be made available, then how is the data received and processed, A more detailed example of fitting for can be provided.
Let us see the C-S-V file. I recommend the 2-letter string "\ n", but you can clear it blank, dash, or even completely.
When you are on it, you may also want to handle the line, punctured "\ r" and make sure to avoid the tab "\ t" backslash characters.
Example (pseudo-code):
stringbuffer s = new stringbuffer (); Four c; Loop-to-character {if (c == '\ n') {// "\ n" with new-line change s.append ("\\ n"); } Change the line-feed with Else if (c == '\ r') {// "\ r" S.append ("\\ r"); } Else if (c == '\ t') {// replace the tab with the space "". S.append (""); } Else {// Otherwise, the character is like adding s.append (c); }} // Process the bytes [] in stringbuffer as you would first process the raw bytes [].
Comments
Post a Comment