将char缓冲区转换为字符串后进行比较。例如:
char[] buffer = { 'h', 'e', 'l', 'l', 'o' }; String str = new String(buffer);
if(str.equals("hello")) { System.out.println("The buffer is equal to the string."); } else { System.out.println("The buffer is not equal to the string."); }