0

私は次のコードに本当に困惑しています:

// Get the content text
String contentText = null;
Header contentEncodingHeader = m_httpEntity.getContentEncoding();
final String contentEncodingValue = contentEncodingHeader != null ? contentEncodingHeader.getValue() : ""; // In my example, this is set to "gzip"

if (contentEncodingValue == "")
{
    contentText = this.GetResponseContentText(inputStream, charset);
}
else if (contentEncodingValue == "gzip")
{
    contentText = this.GetResponseContentText_GZip(inputStream, charset);           
}

return contentText;

コード行をステップ オーバーすると、次の順序で実行されます。

1) if (contentEncodingValue == "")
{
3)  contentText = this.GetResponseContentText(inputStream, charset);
}
2) else if (contentEncodingValue == "gzip")
{
    contentText = this.GetResponseContentText_GZip(inputStream, charset);           
}

4) return contentText;

さらに奇妙なのは、GetResponseContentText関数に入っていないことです。私は本当に混乱しています。誰でもこれに光を当てることができますか?

また、if ステートメントをコメントアウトすると、正常に動作します (GetResponseContentText_GZip関数に入ります)。

4

1 に答える 1

2

equals文字列比較から、代わりに使用したい==

if (contentEncodingValue.equals("")) {
...
}
else if (contentEncodingValue.equals("gzip")) {
...
}
于 2011-05-03T21:34:02.590 に答える