六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 34|回复: 0

自己总结的Java实现文件的读写操作

[复制链接]

升级  36.67%

29

主题

29

主题

29

主题

秀才

Rank: 2

积分
105
 楼主| 发表于 2013-2-3 14:35:30 | 显示全部楼层 |阅读模式
做个笔记,针对java 的file的操作
 1.根据文件名及字符串,写文件
<div style="padding-right: 5.4pt; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; width: 95%; padding-top: 4px;">public static boolean writeJiang(String content,String path,String name)...{
        
try...{
            File file 
= new File(path);
            System.out.println(
"文件的路径是:" + file+"/"+name);
            BufferedWriter fileout 
= new BufferedWriter(new FileWriter(file+"/"+name,true));
            fileout.write(content);
            fileout.write(
" ");
            fileout.flush();
            fileout.close();
        }

        
catch(Exception e)...{
            e.printStackTrace();
        }

        System.out.println(
"写文件完毕");
        
return true;
    }
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

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