other.jsp
<%@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8"%><% StringPath=Request.getcontextpath (); StringBasePath=Request.getscheme ()+ "://" +Request.getservername ()+ ":" +Request.getserverport ()+Path+ "/";%><%@page Import="java.io.*" %><!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"><HTML><Head><Basehref= "<%=basePath%>"><title>My JSP ' other.jsp ' starting page</title></Head><Body> <%File File=NewFile ("C:\\users\\x550v\\desktop","Cc.txt"); if(!file.exists ()) {file.createnewfile (); } //read file information by character input stream/*Char c[]=Newchar[1]; Reader in=Newfilereader (file); try{intN=-1; while((n=In.read (c,0,1))!=-1){ StringStr=New String(c,0,1); Out.print (str); } in.close (); } catch (Exception e) {out.print (e); } */ //writing file information through a character output streamStringStr="let me think twice ."; Char c[]=Str.tochararray ();//string strongly converted to char type Writer o=NewFileWriter (file,true); O.write (c); O.flush (); O.close (); %></Body></HTML>
MyEclipse------file character input, output stream read and write information