If you need to reprint, please indicate the source and the author. Thank you QQ: 221704msn: Flyly@yeah.netemail: zhangfl@sports.cn Example: Read the XML file to generate an XML format JSP file import java.io. *;
public class FileImp {public static void main (String [] args) {FileImp flieimp = new FileImp (); try {BufferedReader in = new BufferedReader (new InputStreamReader (new FileInputStream ( "C: // jbproject // image_test // modules. XML ")," UTF-8 ")); string str = new string (); string newstr ="
}
public void write (String aString) {try {Writer out = new BufferedWriter (new OutputStreamWriter (new FileOutputStream ( "C: //jbproject//image_test//modules.jsp"), "GB2312")); out.write (aString ); out.close ();} catch (FileNotFoundException ex) {ex.printStackTrace ();} catch (UnsupportedEncodingException ex) {ex.printStackTrace ();} catch (IOException ex) {ex.printStackTrace ();}}} This is a problem that is encountered in practical applications. Since the generated file is saved in the UTF-8 encoding method. If you do not press in the specified encoding method, it will be ranked in the other file generated. The above coding method can be changed according to your needs. This is just an example