Append Data to a file

zhaozj2021-02-16  57

/ ** 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 ();

转载请注明原文地址:https://www.9cbs.com/read-21435.html

New Post(0)