I saved a line by line string in database . But when accessing the string from DB ,i was not able to get the line by line string. Instead the whole string is coming as one single block. What could be the reason? Any alternatives?
Asked
Active
Viewed 1,358 times
0
-
@user1722444 I'm not quite sure what you mean. A string value is still a single "block", even if it contains line feeds. Do you mean that the line feed is missing, or is getting all text at once - including a line feed - the unexpected thing? – Joachim Isaksson Jul 23 '13 at 05:26
-
@JoachimIsaksson : 'line1 \n line2 \n ... ' etc is the saved string. But i'm getting 'line1line2' in return – Vivek Jul 23 '13 at 05:38
-
@jWeavers: Its an Oracle database – Vivek Jul 23 '13 at 05:38
-
It can't be, Always select query return 'line1 \n line2 \n ... ' as it is. You can split your string later – Ruchira Gayan Ranaweera Jul 23 '13 at 05:53
1 Answers
1
You might have to unescape the \n
from string retrieved from databse.
You can use StringEscapeUtils.unescapeJava.
Similar question : Java is not treating "\n" as new line when retrieved from Database column