Example of reading documents **************************************************************** ***** <% @ Page ContentType = "text / html; charset = GB2312"%> <% // variable declaration / java.lang.string strfilename; // file name java.io.file objfile; // file Object java.io.fileReader objfileReader; // read file object char [] chrbuffer = new char [10]; // buffer int inTlength; // actually read the number of characters (one Chinese is a character) // Set to read File name strfilename = "d: //test.txt"; // Create a file object objfile = new java.io.file (strfilename); // Determine if the file exists if (Objfile.exists ()) {// file exists // Create a read file object ObjfileReader = new java.io.fileReader (objfile); // read the content while (intlength = objfileReader.read (chrbuffer)! = - 1) {// Out Out.write (chrbuffer, 0, intlength);} // Close the read file object objfileReader.close ();} else {// file does not exist Out.println ("The following file does not exist:" strfilename);}%> ****** **************************************************************************************************** *********************************************************************************** Objects can write the Text file. Please refer to the following example: <% @ page import = "java.io. *"%> <% string str = "print me"; // always give the path from root. This way it almost always works. String nameOfTextFile = " /usR/anil/imp.txt "; try {printwriter pw = new fileoutputstream (NameOfTextFile); PW.Println (STR); // clean Up Pw.close ();} catch (ooException e) {OUT .println (E.GetMessage ());}%> Now, open Imp.txt to view, string "Print Me" should have been written. There is another method, using the file tag of the IN16 tag library, refer to http://sourceforge.net/project/?group_id=1282. The syntax of the example is: