String txt = area.getText();
try{
File file = new File("Infor.txt");
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
out.write(txt);
out.close;
}catch(Exception e){}
try{
File file = new File("Infor.txt");
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
out.write(txt);
out.close;
}catch(Exception e){}
///////////////////////////文件拷贝/////////////////////////////////////////////
// 参数: from 源路径。
// 参数: to 目标路径。
// exception IOException Description of the Exception
///////////////////////////////////////////////////////////////////////////////
public static void copy( String from, String to ) throws IOException {
int BUFF_SIZE = 100000;
byte[] buffer = new byte[ BUFF_SIZE ];
InputStream in = null;
OutputStream out = null;
try{
in = new FileInputStream( from );
out = new FileOutputStream( to ); while ( true ){
synchronized ( buffer ){
int amountRead = in.read( buffer );
if ( amountRead == -1 ){
break;
}
out.write( buffer, 0, amountRead );
}
}
}
finally {
if ( in != null ){
in.close();
}
if ( out != null ){
out.close();
}
}
}
<%
StringBuffer txtConcent = new StringBuffer() ;
String sSrcName="c:\\test.txt";
txtConcent.append("abc") ;try
{
java.io.PrintWriter pw = new java.io.PrintWriter(new java.io.FileWriter(sSrcName, true), true);//注意true的用法 pw.println(txtConcent);
pw.close();
}
catch (Exception e)
{
}
%>
在与你编译生成的CLASS文件的同一个目录里,要么你也可以单独指定这个文件的位置如
File file = new File("c:\\Infor.txt");