Created
December 29, 2011 10:43
Pimping the String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit def toRichString(s:String) : RichString = new RichString(s) | |
class RichString(s: String){ | |
def saveAs(fileName: String) = write(fileName, s) | |
private[this] def write(fileName: String, content: String) { | |
val f = new FileWriter(fileName) | |
f.write(content) | |
f.close() | |
} | |
} | |
"My string I want to save".saveAs("some/file/name.txt") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment