在 Google App-Engine JAVA 中将文本转换为字符串,反之亦然
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2819896/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Converting Text to String and vise-versa in Google App-Engine JAVA
提问by Manjoor
How can one convert from String to Text
如何从字符串转换为文本
java.lang.String
to
到
com.google.appengine.api.datastore.Text;
and vise-versa?
反之亦然?
采纳答案by 0x2D9A3
Check Javadocabout Text
class. It has two methods: toString()
and getValue()
.
But toString()
returns first 70 characters only.
检查关于类的JavadocText
。它有两种方法:toString()
和getValue()
。但只toString()
返回前 70 个字符。
So, use getValue()
instead:
因此,请getValue()
改用:
String value = someText.getValue();
Contructor of the Text
class supports initialization with a string value. And (as Javadoc says), this object cannot be modified after construction.
Text
类的构造函数支持使用字符串值进行初始化。并且(如 Javadoc 所说),该对象在构造后无法修改。