Well that was pretty much my question, I need to do something like this:
String scriptContent = \"print(\"Hello World\")\";
You can use escape character to do this
String scriptContent = "print(\"Hello World\")";
You're looking for something called an escape sequence, which is a way of telling Java to interpret a particular character as something other than what it means by default. In your case, you can make a Java string containing a double-quote by prefixing it with a slash:
String scriptContent = "print(\"Hello World\")";
There are many other escape sequences in Java. For example, \\
stands for a slash character itself (instead of the start of another escape sequence!); \'
stands for a single quote; and \n
stands for a newline. There are many others; consult a Java reference for more details.
Use \"
.
String scriptContent = "print(\"Hello World\")";
apache commons has a StringEscapeUtils http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/StringEscapeUtils.html