Skip to content

Instantly share code, notes, and snippets.

@henix
Created June 21, 2013 09:18
Show Gist options
  • Save henix/5829996 to your computer and use it in GitHub Desktop.
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
# 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