tags:

views:

85

answers:

3

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"&gt;

thanks

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

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

skaffman
A: 

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'&gt;
Winter
A: 

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