-2

How can I assign this string in a Java String?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

thanks

Noona
  • 643
  • 1
  • 14
  • 30

3 Answers3

5
String s = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";

i.e. replace the " characters with the escaped form, \"

skaffman
  • 398,947
  • 96
  • 818
  • 769
0

You could also use single quotes instead of double quotes. Then it wouldn't be an issue.

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
Winter
  • 1,490
  • 3
  • 13
  • 21
0

And you may read the string from an external source like a file, a database or from a JTextField or something similar. Maybe from an Url. :)

user unknown
  • 35,537
  • 11
  • 75
  • 121