字符串数组不能操作其他字符串 [英] String Arrays can't operand other String
本文介绍了字符串数组不能操作其他字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对不起,我的英语不好,很累:(
问题是
Sorry about my bad English, is very pool:(
Question is
package test.get;
import java.io.BufferedInputStream;
import java.net.URL;
import java.net.URLConnection;
import org.apache.http.util.ByteArrayBuffer;
import org.apache.http.util.EncodingUtils;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ScrollView;
import android.widget.TextView;
public class dataaaaaa extends Activity {
/** Called when the activity is first created. */
TextView Tview =null;
ScrollView scrollView=null;
String delimiter = ",";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Tview= new TextView (this);
scrollView = new ScrollView(this);
URLConnection ucon=null;
BufferedInputStream bis=null;
ByteArrayBuffer bab= null;
try{
URL url=new URL("http://192.192.140.217:8081/load/show.php");
ucon=url.openConnection();
bis=new BufferedInputStream(ucon.getInputStream());
int current=0;
bab=new ByteArrayBuffer(2);
while((current=bis.read())!=-1){
bab.append((char)current);
}
}catch(Exception e)
{
e.printStackTrace();
}finally{
try{
if (bis != null){
bis.close();
}
}catch(Exception e){
e.printStackTrace();
}
}
String str = EncodingUtils.getString(bab.toByteArray(),"UTF-8");
String[] result = str.split(delimiter);
if ("1"==result[0])
{
Tview.setText("Angry");
scrollView.addView(Tview);
this.setContentView(scrollView);
}else{
Tview.setText("Happy");
scrollView.addView(Tview);
this.setContentView(scrollView);
}
}
}
而且它不能操作数....
我非常确定result [0]是"1"
所以肯定会返回"Angry",但不会.
and it cant operand....
I''m very sure in result[0] is "1"
so it sure be return "Angry" but it not.
推荐答案
好吧...我发现可以自己解决; p
它需要对字符串使用"if(result [0] .equals("1"))".
它的愚蠢问题; p
okay... I found to solution by myself ;p
its need to use "if (result[0].equals("1"))" for String.
Its Stupid question ;p
这篇关于字符串数组不能操作其他字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文