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

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

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

unit testing - How to mock PreferenceManager in Android? -