java - Trying to not Omit Leading 0's when writing from Int to Hex using buffered writer -


i create buffered writer

bufferedwriter errorreport = new bufferedwriter(new filewriter("errorreport.txt")); 

then wanted write while converting integer hex.

  errorreport.write(integer.tohexstring(version)) 

this works perfectly, except omits leading 0's writes minimum possible length. 'version' byte in length , prints 6. know actual value 06. how keep these leading 0's?

i tried errorreport.write(string.format("%03x", integer.tohexstring(version)), error illegalformatconversionexception x != java.lang.string

the x specifies hexadecimal format perform conversion passing integer directly

errorreport.write(string.format("%03x", version));  

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -