<% @ page import = "java.io. *"%>
lion interactive network == "JSP read file and writing file example title> head> <% // write file string str = "www.lionsky.net"; string filename = request.getRealPath ("lionsky.txt"); java.io.file f = new java.io.file (filename); if ( ! f.exists ()) // If the file is not stored, {f.createNewFile ();} tryoutPutWriter PW = new printwriter (fileoutputstream (filename)); PW.Println (STR); // Write content PW.Close ();} catch (ieException e) {out.println (E.GetMessage ());} // read file java.io.fileReader fr = new java.io.fileReader (f); char [] buffer = New char [10]; int LENGTH; // read the number of characters (one Chinese is a character) // read file content out.write (filename "
"); while ((length = fr.read) Buffer)! = - 1) {// Output Out.write (Buffer, 0, Length);} fr.close ();%> body> html> <% // write file string str = " Www.lionsky.net "; string filename = request.getRealPath (" lionsky.txt "); java.io.file f = new java.io.file (filename); if (! F.exists ()) // If If the file is not stored, {f.createNewFile ();} tryoutwriter (new fileoutputstream (fileoutPutStream (filename)); PW.Println (STR); // Write content PW.Close ();} catch (ioException e) {outputln (E.GetMessage ());} // read file java.io.fileReader fr = new java.io.fileReader (f); char [] buffer = new char [10]; intleth; // read the number of characters (one Chinese is a character) // read the file content out.write (filename ""); while ((length = fr.read (buffer))! = - 1) {// Output Out.write (buffer, 0, length);} fr.close ();%>