package com.wondream.myframework.app.basictest.io; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.jupiter.api.Test; import java.io.File; import java.io.FileOutputStream; import java.text.SimpleDateFormat; import java.util.Date; public class FileOutputStreamTest { private final Log logger = LogFactory.getLog(FileOutputStreamTest.class); @Test public void excute(){ File file = null; FileOutputStream fileOutputStream = null; try { StringBuilder pathname = new StringBuilder("./logs/"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); pathname.append(formatter.format(new Date())).append(".log"); file = new File(pathname.toString()); fileOutputStream = new FileOutputStream(file, true); String var1 = " 是兄弟就来砍我!"; fileOutputStream.write(var1.getBytes("UTF-8")); fileOutputStream.close(); }catch (Exception e){ } } }
FileOutputStream的基本使用
最新推荐文章于 2024-08-14 11:46:33 发布