package com.chen.jdk;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
public class TestLog {
public static void main(String[] args) {
Random random = new Random();
String str = "";
int status = 0;
for (int j = 0; j < 15; j++) {
for (int i = 0; i < 16; i++) {
str += random.nextInt(10);
}
status++;
String temp = (status)
+ "="
+ str
+ "="
+ (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(new Date())).toString();
System.out.println(temp);
String newline = "\r\n";
try {
FileOutputStream fos = new FileOutputStream(new File(
"F:\\log.txt"), true);
fos.write(temp.getBytes());
fos.write(newline.getBytes());
fos.flush();
} catch (Exception e) {
e.printStackTrace();
}
str = "";
}
}
}