org.jdom.IllegalDataException: The data ""is not legal for a JDOM attribute: 0xb is not a legal 异常

今天用jdom生成xml,在操作中出现了 org.jdom.IllegalDataException: The data ""is not legal for a JDOM attribute: 0xb is not a legal 异常,仔细跟踪发现,在原有的组建对象的属性中出现了异常字符,通过下面的替换,再重新转换成String,trim后正常。
  1.     char [] xmlChar = paragraph.toCharArray();  
  2.     for (int i=0; i < xmlChar.length; ++i) {  
  3.     if (xmlChar[i] > 0xFFFD)   
  4.     {   
  5.        //直接替换掉0xb   
  6.         xmlChar[i] =' ';  
  7.     }   
  8.     else if (xmlChar[i] < 0x20 && xmlChar[i] != 't' & xmlChar[i] != 'n' & xmlChar[i] != 'r')  
  9.     {  
  10.        //直接替换掉0xb  
  11.         xmlChar[i] =' ' ;  
  12.     }  
  13.     }  

你可能感兴趣的:(xml,String)