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

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -