Created
June 21, 2013 09:18
-
-
Save henix/5829996 to your computer and use it in GitHub Desktop.
Encode a file into a Java string, with newline inserted at each \n
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
# http://stackoverflow.com/questions/1251999/sed-how-can-i-replace-a-newline-n | |
:a | |
N | |
$!ba | |
s/\\/\\\\/g | |
s/"/\\"/g | |
s/\r/\\r/g | |
s/\t/\\t/g | |
s/\f/\\f/g | |
s/\n/\\n" +\n"/g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment