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
Post a Comment