java - System.lineSeparator() not working as expected on Windows -


i have method takes string input, , takes away spaces , newline characters on it. achieve i'm using following methods java libraries:

public string clean(string s) {     return s.replaceall(system.lineseparator(),"").replaceall(" ",""); } 

this working fine under linux, when comes windows, isn't able remove line separator characters, string contains them.

is there i'm missing? know in unix based systems newline character /n , have no clue might in windows, java documentation says, system.lineseparator() method should provide platform-independent line separator character.

i suggest try removing spaces

public static string clean(string s) {     return s.replaceall("\\s+", ""); } 

i suspect problem have reading files written on windows on linux box. code won't remove \r have on windows.


Comments

Popular posts from this blog

c++ - End of file on pipe magic during open -

basic authentication with http post params android -

data.table making a copy of table in R -