Java中如何将一个较长的字符串分成多行了书写

如题所述

第1个回答  2018-05-26
把大的list分成一个个小的list, 再用map储存
第2个回答  2018-06-05
这个还真不好说。。

如果说只是String字符串的话,
String str = "aaaa\nbbbbbb\nccc";
String[] len = str.split("\n");

System.out.println(len.length);
但是你要是从inputStream之类的读取,用BufferedReader之类的吧本回答被网友采纳
第3个回答  2020-12-15

You can use auto-formatting (CTRL + ALT + L), after few changes in Code Style settings.

    Press CTRL + ALT + S to open Settings window

    Find Code Style / Java section

    Make sure to uncheck "Line Breaks" option and check "Ensure right margin is not exceeded" option

    Press OK to accept changes you've made

    Now when using auto-formatting (CTRL + ALT + L) long strings exceeding line character limit will be automatically cut into multiple lines.

相似回答