How to write a file in new line using java code
I having a text like Apple|MicroSoft|Oracle|Windows|Mac|.I wish to print like Apple Microsoft Oracle Windows Mac.
I used .split() keword, but it prints like, A p p l e | M i c r o s o f t | ...
why it wi开发者_Go百科ll print like this if any alternate solution for this. Thanks in advance.
This should work:
String name = "Apple|MicroSoft|Oracle|Windows|Mac|";
name = name.replaceAll("\\|", " ");
For this particular example, just use replace() to switch out the | characters with spaces
If using the split() function, try .split("|")
精彩评论