1

我的问题是这个角色:"

String myLine = "<?xml version="1.0" standalone="yes"?><kml xmlns="http://earth.google.com/kml/2.2">";

"我想将此行写入文件,但是由于我要编写的文本中的字符,此代码不起作用。如何在代码中更改此字符以使其工作但可在文件中显示?

4

2 回答 2

4

用 \ 转义字符,所以它会是 \"。

见这里:http: //developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling

于 2013-08-05T15:11:22.963 回答
0

您需要在带有 '\'s 的引号之前添加转义符。

String myLine = "<?xml version=\"1.0\" standalone=\"yes\"?><kml xmlns=\"http://earth.google.com/kml/2.2\">";
于 2013-08-05T15:12:24.923 回答