利用流的知识实现一个简陋的控制台日志功能
作者:互联网
import java.io.*; import java.util.*; public class SimpleLog{ public static void main(String[] args){ try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new FileWriter("D:/Java/SimpleLog/Log.txt",true)); String str = null; while(!(str = br.readLine()).equalsIgnoreCase("exit")){ pw.println(str); pw.println("===" + new Date() + "==="); } br.close(); pw.close(); } catch(IOException e){ e.printStackTrace(); } } }
标签:PrintWriter,pw,简陋,str,br,close,new,控制台,日志 来源: https://www.cnblogs.com/yxfyg/p/12403624.html