开发者

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("|")

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜