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(); }
}