Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to compare a byte  RSS feed

 
sri_dynamo
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to read a byte stream and in particular trying to know if I have encountered #04-1 byte and #2A another byte..
below is the code...
I am having trouble at if((previous=="#04")&&(current=="#2A")), how do I compare the value that I have in "previous" with that of "current"?
thanks in advance
I have a DataInputStream dis;
boolean status=false;
n = dis.available();
if (n >= 0) {
byte[] b = new byte[1];
int result = dis.read(b);
previous=b[0];
}
while (n > 0 && status==false) {
//System.out.println("4");
byte[] b1 = new byte[1];
int result = dis.read(b1);
current=b1[0];
System.out.println("5");
//
if((previous=="#04")&&(current=="#2A"))
{
System.out.println("got match");
status=true;
}
else
previous=current;
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!