package io;
import java.io.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
/*
* 修改日期:2020/04/05
* 修改人:牟松
* 字符流BufferedWriter和BufferedReader基本操作练习
* 修改日期:2020/04/05
* 修改人:牟松
* 字符流BufferedWriter和BufferedReader基本操作练习
* 特点BufferedReader可以一行一行的读取
*/
*/
public class ceshi {
public static void main(String[] args)
{
/*
//实例化BufferedWriter对象
BufferedWriter bw = new BufferedWriter(new FileWriter ("ceshi.txt",true));
//获取当前时间
DateFormat bf = new SimpleDateFormat("yyyy-MM-dd E a HH:mm:ss");
Date date = new Date();
String format = bf.format(date);
bw.write(format+":"+"测试文本"+ " ");
bw.close();*/
try {
/*
//实例化BufferedReader对象
BufferedReader br = new BufferedReader(new FileReader("ceshi.txt"));
while(true)
{
char[] string=new char[1024];
//读取这一行的内容
br.read(string);
System.out.println(new String(string));
//读取下一行内容
if(br.readLine()==null)
break;
}
br.close();*/
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void main(String[] args)
{
/*
//实例化BufferedWriter对象
BufferedWriter bw = new BufferedWriter(new FileWriter ("ceshi.txt",true));
//获取当前时间
DateFormat bf = new SimpleDateFormat("yyyy-MM-dd E a HH:mm:ss");
Date date = new Date();
String format = bf.format(date);
bw.write(format+":"+"测试文本"+ " ");
bw.close();*/
try {
/*
//实例化BufferedReader对象
BufferedReader br = new BufferedReader(new FileReader("ceshi.txt"));
while(true)
{
char[] string=new char[1024];
//读取这一行的内容
br.read(string);
System.out.println(new String(string));
//读取下一行内容
if(br.readLine()==null)
break;
}
br.close();*/
} catch (Exception e) {
e.printStackTrace();
}
}
}