1.[文件]
Practise3.java~2KB
下载(22)
package chapter4;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class Practise3 {
/**
* @param args
*/
public static void main(String[] args) throws IOException {
// TODO 自动生成的方法存根
int serialNumber = 0;
File testFile = new File("Practise3.txt");
BufferedWriter outBufferedWriter = new BufferedWriter(new FileWriter(
testFile));
do {
int firstNumber = (int) (Math.random() * 10000);
int secondNumber = (int) (Math.random() * 10000);
if (firstNumber > secondNumber) {
// System.out.println(serialNumber + ": " + "firstNumber: "
// + firstNumber + "大于SecondNumber: " + secondNumber);
outBufferedWriter.write(serialNumber + ": " + "firstNumber: "
+ firstNumber + "大于SecondNumber: " + secondNumber
+ '\n');
serialNumber += 1;
} else if (firstNumber < secondNumber) {
// System.out.println(serialNumber + ": " + "firstNumber: "
// + firstNumber + "小于SecondNumber: " + secondNumber);
outBufferedWriter.write(serialNumber + ": " + "firstNumber: "
+ firstNumber + "小于SecondNumber: " + secondNumber
+ '\n');
serialNumber += 1;
} else {
// System.out.println(serialNumber + ": " + "firstNumber: "
// + firstNumber + "等于SecondNumber: " + secondNumber);
outBufferedWriter.write(serialNumber + ": " + "firstNumber: "
+ firstNumber + "等于SecondNumber: " + secondNumber
+ '\n');
serialNumber += 1;
}
// outBufferedWriter.close();
} while (true);
}
}