CSDN博客

img whxbb

Append Data To A File

发表于2004/6/23 10:16:00  822人阅读

分类: java source snippets

/** author:whxbb*/

    public void log(String fileName, String content) throws Exception
    {
        String logMsg = new Date().toLocaleString() + ":" + content + "/r/n";
        ByteBuffer bbf = ByteBuffer.wrap(logMsg.getBytes());
        File file = new File(fileName);
        if (!file.exists())file.createNewFile();
        boolean append = true;
        FileChannel wChannel = new FileOutputStream(file, append).getChannel();
        wChannel.write(bbf);
        wChannel.close();
    }

0 0

相关博文

我的热门文章

img
取 消
img