日期:2014-05-20 浏览次数:20774 次
import java.io.*; public class ReadFileRW { public static void main(String []args) { StringBuffer sb=new StringBuffer(); char ch; try { while((ch=(char)System.in.read())!="\n") { sb.append(ch); } RandomAccessFile raf=new RandomAccessFile("D:\\HelloWorld\\User.txt","rw"); raf.seek(raf.length()); raf.writeBytes(sb.toString()); raf.close(); }catch(Exception e) { e.printStackTrace(); } } }