java.lang.NumberFormatException: For input string: "N"

public void setReceiveMsg(String receiveMsg){
// 获取接受日期
String date = receiveMsg.substring(0, 8);
// 获取字体格式
String fontType = receiveMsg.substring(8, 12);
// 接受信息内容
receiveMsg = receiveMsg.substring(12);

receiveEditText.insertUserString(myFriend.getNickName() +" "+ date,
new Color(0,0,255));
// 设置字体
receiveEditText
.setFontStyle(fontPanel.getFontName(Integer.parseInt(fontType
.substring(0, 1))), // 字体名称
//问题出在这
fontPanel.getFontColor(Integer.parseInt(fontType
.substring(1, 2))),// 字体颜色
Integer.parseInt(fontType.substring(2, 3)), // 字体格式
fontPanel.getFontSize(Integer.parseInt(fontType
.substring(3, 4)))); // 字体大小
// 显示信息.
receiveEditText.insertToTextPanel(receiveMsg);

}
最新回答
素觞流年

2025-03-28 07:02:32

// 获取字体格式
String fontType = receiveMsg.substring(8, 12);
你可以打印一下这个String类型的变量看一下,应该是这里的问题
导致下面转换成int类型的时候因为字符串中包含无法转换的字符导致的