How do I use System.getProperty(“line.separator”).toString()?

前端 未结 7 1115
Happy的楠姐
Happy的楠姐 2020-12-29 05:41

I have a Tab-delimited String (representing a table) that is passed to my method. When I print it to the command line, it appears like a table with rows:

http://i.st

7条回答
  •  梦毁少年i
    2020-12-29 05:56

    I think your problem is that String.split() treats its argument as a regex, and regexes treat newlines specially. You may need to explicitly create a regex object to pass to split() (there is another overload of it) and configure that regex to allow newlines by passing MULTILINE in the flags param of Pattern.compile(). Docs

提交回复
热议问题