-1

Sorry for the vague question, but: If I had some text in a jTextArea, which contained some code (java, for example), how would I be able to convert that into a value which could then be used as a string, eg " would become \"?

E.g. I get the below result:

String a = "helloworld";

And put it back into the jTextArea with this result:

"String a = \"helloworld\";"

Note: the jTextArea.getText(); method does not return the correct result

user2976089
  • 345
  • 4
  • 14
  • for better help sooner post an SSCCE, short, runnable, compilable, reproduced your description here – mKorbel Dec 02 '13 at 19:29
  • possible duplicate of [how to compile & run java program in another java program?](http://stackoverflow.com/questions/4842684/how-to-compile-run-java-program-in-another-java-program) – durron597 Mar 04 '14 at 17:32

1 Answers1

1

You could simply use JTextArea.getText() it's automatically escaped.

Arpit
  • 955
  • 7
  • 11