byte之间如何比较啊???谢谢!!
protected static final byte[] HEADER_SEPARATOR = {0x0D, 0x0A, 0x0D, 0x0A};
public String readHeaders()
throws MalformedStreamException
{
int i = 0;
byte b[] = new byte[1];
StringBuffer buf = new StringBuffer();
int sizeMax = HEADER_PART_SIZE_MAX;
int size = 0;
byte result[] = new byte[sizeMax];
do
{
if(i >=4 )
break;
try
{
b[0] = readByte();
}
catch(IOException e)
{
throw new MalformedStreamException("Stream ended unexpectedly");
}
size++;
if(b[0] == HEADER_SEPARATOR)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
operator == cannot be applied to byte,byte[]
i++;
else
i = 0;
if(size <= sizeMax)
result[size-1]=b[0];
}while(true);
if(size<=sizeMax)
{
byte headers[] = new byte[size];
System.arraycopy(result,0,headers,0,size);
try
{
return new String(headers,"utf-8");
}
catch(Exception e)
{
e.printStackTrace();
}
}else{
try
{
return new String(result,"utf-8");
}
catch(Exception e)
{
e.printStackTrace();
}
}
return null;
}