java 文件读写
上一篇 /
下一篇 2010-07-20 19:02:05
/ 个人分类:java
读操作:
BufferedReader br=new BufferedReader(new FileReader(source_file_path));
StringBuffer sb=new StringBuffer();
while((plaintext=br.readLine())!=null){
}
br.flush();
br.close();
写操作:
FileOutputStream pw = new FileOutputStream(encrypt_file_path,true); /* 此处需要true是在原有内容上追加,不要的话,是覆盖
*/
File file_encrypt=new File(encrypt_file_path);
if(!file_encrypt.exists()){// 如果文件不存在,创建文件
file_encrypt.createNewFile();
}
String str_txt="abc";
pw.write(txt.getBytes());
pw.flush();
pw.close();
收藏
举报
TAG: