import java.io.*;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Scanner;
public class Tool {
public static void main (String [] args)
throws IOException { String Record; 
String name;
String quantity;
String cost;
int num1 = 0, num2 = 0, Total = 0;
// create new buffered output writer
PrintWriter pw = new PrintWriter (new 
BufferedWriter (new FileWriter ("hardware.dat",true)));
//creat a input stream
BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));

Scanner console = new Scanner (System.in);

do{

//
System.out.println("Enter the RecordNumber");
Record = console.nextLine();


System.out.println("Enter Tool Name");
name = console.nextLine ();
try{//make sure user put correct data
System.out.println("Enter Quantity");
quantity = console.nextLine ();
num1 = Integer.parseInt(quantity);
System.out.println("Cost per item(A$)");
cost = console.nextLine();
num2 = Integer.parseInt(cost);
}
catch (NumberFormatException nfe) {//wrong input
  System.err.println("Invalid input format. "+"Exiting ...");
System.err.println(nfe);
System.exit(1);
}

pw.println(""+Record+"\t"+""+name+"\t"+num1+"\t"+num2+"\t"+"\r");
System.out.println("Continue y/n ?"); } while (console.nextLine ().charAt(0) == 'y');
pw.close();
}

}
我现在想防止Record重复, 应该怎么做啊!