java - How do I get a platform-dependent new line character? -


how platform-dependent newline in java? can’t use "\n" everywhere.

in addition line.separator property, if using java 1.5 or later , string.format (or other formatting methods) can use %n in

calendar c = ...; string s = string.format("duke's birthday: %1$tm %1$te,%1$ty%n", c);  //note `%n` @ end of line                                  ^^  string s2 = string.format("use %%n platform independent newline.%n");  //         %% becomes %        ^^ //                                        , `%n` becomes newline   ^^ 

see java 1.8 api formatter more details.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -