http://stackoverflow.com/questions/19388037/converting-characters-to-integers-in-javajava
這個函數能夠用於將char的值輸出ide
Character.getNumericValue(c)
這個函數能夠將值轉爲字符輸出函數
If you simply want to cast the value in the int, you can cast it using Java's typecast notation:idea
int i = 97; // 97 is 'a' in ASCII char c = (char) i; // c is now 'a'
若是你在編譯器裏面輸出結果,你會發現是亂碼,緣由是什麼呢?參考spa
Most answers here propose shortcuts, which can bring you in big problems if you have no idea what you are doing. If you want to take shortcuts, then you have to know exactly what encoding your data is in.code
Whenever java talks about characters in its documentation, it talks about 16-bit characters.ci
You can use a DataInputStream
, which has convenient methods. For efficiency, wrap it in a BufferedReader
.get
http://stackoverflow.com/questions/833709/converting-stream-of-ints-to-chars-in-java編譯器