scala - Reading and filtering a file into a string -


i new scala , need read contents of text file string while removing lines @ same time. lines removed can identified substring match. come following solution, works, problem newlines removed:

val fileasfilteredstring = io.source.fromfile("file.txt").getlines.filter(s => !(s contains "filter these")).mkstring; 

how can keep newlines?

add parameters mkstring:

val fileasfilteredstring = io.source.fromfile("file.txt").getlines     .filter(s => !(s contains "filter these")).mkstring("\n") 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -