我試圖從服務器獲取文本,然後檢查它,知道採取的文本採取了哪些操作。問題是,當我嘗試檢查接收到的文本是否爲「已退出」時,如果收到的文本確實是「已退出」,則查詢總是返回值「false」。Eclipse - 函數問題
下面是代碼:
class Get_Message_From_Server implements Runnable
{
public void run()
{
InputStream iStream = null;
try
{
iStream = Duplex_Socket_Acceptor.getInputStream();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
//Create byte array of size image
byte[] Reading_Buffer = null;
try
{
Reading_Buffer = new byte [Duplex_Socket_Acceptor.getReceiveBufferSize()];
//New_Buffer = new byte [100];
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
byte[] Byte_Char_1 = new byte[1];
int Byte_String_Lenght = 0;
//read size
try
{
iStream.read(Reading_Buffer);
String Reading_Buffer_Stream_Lenghtor = new String(Reading_Buffer);
//System.out.println("full : " + Reading_Buffer_Stream_Lenghtor);
Byte_String_Lenght = Reading_Buffer_Stream_Lenghtor.indexOf(new String(Byte_Char_1));
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
//Convert to String
Meassage = new String(Reading_Buffer);
Meassage = Meassage.substring(0, Byte_String_Lenght);//The text that received
Message_Getted = 1;
}
}
查詢:
if(Message_1 != "Exited")//the message query
{
System.out.println("Continued 253");
continue;
}
它總是返回值 - 假
- 其知道該消息是UTF重要 - 8編碼
所以我怎麼能解決這個問題?
沒有,我檢查這個和它沒有工作給我。這就是爲什麼我問這個問題... – anri97