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

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

Android Gson.fromJson error -