Skip to content

Instantly share code, notes, and snippets.

@AlexKordic
Created November 20, 2013 10:18
Show Gist options
  • Select an option

  • Save AlexKordic/7560855 to your computer and use it in GitHub Desktop.

Select an option

Save AlexKordic/7560855 to your computer and use it in GitHub Desktop.
insert code in java source as string.
def to_java_multiline_string(txt, indent=1):
formated = ['"' + line.replace('\\', '\\\\').replace('"', '\\"').replace('\t', '\\t') + '\\n"' for line in txt.splitlines()]
separator = "\n{0}+ ".format("".join(["\t"] * indent))
return separator.join(formated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment