java - Error using bit shift operator -
this question has reply here:
java: not statement 2 answersi using next code convert 0 , 1's string binary , write file.
i getting error @ line 4:
code.java:56: error: not statement nextbyte << 1;
code:
public void writetofile(string binarystring, outputstream os){ int pos = 0; while(pos < binarystring.length()){ byte nextbyte = 0x00; for(int i=0;i<8 && pos+i < binarystring.length(); i++){ nextbyte << 1; nextbyte += binarystring.charat(pos+i)=='0'?0x0:0x1; } os.write(nextbyte); pos+=8; } }
you should assign result of operator variable :
nextbyte = nextbyte << 1;
java
No comments:
Post a Comment