现在的位置: 首页 > 综合 > 正文

java io 写入写出

2017年12月07日 ⁄ 综合 ⁄ 共 671字 ⁄ 字号 评论关闭

public class jian {
 public  static void main(String [] args) throws IOException{
  
        FileWriter fw=new FileWriter("D://xor.txt",true);
  fw.append(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date())+"/r/n"); 
  fw.flush();
        //FileWriter fw=new FileWriter("D:/xor.txt",true);
  
 
 File file = new File("D://xor.txt");
    BufferedReader readIn = new BufferedReader(new FileReader(file));
    StringBuffer s = new StringBuffer();
    String str = null;
    while((str=readIn.readLine())!=null)
    {
     s.append(str +"/n");
    }
  
    String aa=s.toString().trim();
    System.out.println(aa);
    if("中国".equals(aa)){
     System.out.println("ok");
    }else{
     System.out.println("erro");
    }
    readIn.close();
 }

}

抱歉!评论已关闭.