六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 12|回复: 0

java 写文件

[复制链接]

升级  82%

11

主题

11

主题

11

主题

童生

Rank: 1

积分
41
 楼主| 发表于 2013-2-3 10:40:53 | 显示全部楼层 |阅读模式
/** * 写文件 * @param string * @param toFile */public static void writetoFile(String string,String toFile){RandomAccessFile rf = null;   try {System.out.println("续写状态,写文件开始>>>>>>>");rf = new RandomAccessFile(toFile,"rw");    rf.seek(rf.length());    rf.writeBytes(string+"\n");    System.out.println("写文件结束>>>>>>>,文件名为:"+toFile);   } catch (IOException e) {   System.out.println("写入文件失败:Error ---->"+e.getMessage());   }finally{   if(rf!=null){   try {rf.close();} catch (IOException e) {System.out.println("关闭rf失败:Error ---->"+e.getMessage());}   }   }}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表