In an xss problem encountered in this encoding problem, utf-7 and mutf-7 this encoding is used by mail, javamail should be supported, using utf-7 this is still relatively rare encoding can be used for some xss applications. Using Native jdk reports an error that does not support utf-7 encoding, which is a bug in sun jdk. Open-source jcharset. jar is a solution. You can use this jar package after buildpath. I wrote a small program and transferred the code!
Public static void main (String [] args) {// write the utf-7 encoding format to be escaped in bf, write a txt // in UTF-8 format on disk d to construct stringbufferStringBuffer bf = new StringBuffer ("+ buffers-"); try {OutputStream outputStream = new FileOutputStream ("d: \ utf-8.txt "); OutputStreamWriter outputStreamWriter = new OutputStreamWriter (outputStream," UTF-8 "); // display the format of the file encoding. // System. out. println (outputStreamWriter. getEncoding (); // write BufferedWriter bufferedWriter = new BufferedWriter (outputStreamWriter); bufferedWriter. write (new String (bf. toString (). getBytes ("UTF-8"), "utf-7"); bufferedWriter. flush (); bufferedWriter. close (); bufferedWriter = null;} catch (FileNotFoundException e) {e. printStackTrace ();} catch (UnsupportedEncodingException e) {// TODO Auto-generated catch blocke. printStackTrace ();} catch (IOException e) {// TODO Auto-generated catch blocke. printStackTrace ();}