java - Getting little boxes instead of actual characters -


i reading stream using inputstream. code below

buffer = new byte[8]; try {     while (inputstream.available() > 0) {         int numbytes = inputstream.read(buffer);         system.out.println(new string(buffer, 0, numbytes));     } } catch (exception ex) {     ex.printstacktrace(); } 

but instead of getting characters getting below

enter image description here

what these , how can actual characters.

you need supply appropriate character set argument string constructor. (that's 4th argument - missing in code - , has wrong default data.)

otherwise string misinterpret data.

you may find that

java.nio.charset.charset.forname("utf-8")

is 1 need.


Comments