File RaptorsFile = new File("raptors.txt");
File tempFile = new File("raptorstemp.txt");
BufferedWriter output = new BufferedWriter (new FileWriter ("raptorstemp.txt"));
System.out.println("Please enter the following infomation");
System.out.println("Please enter the Player's Name");
String PlayerName=sc.nextLine();
System.out.println("Please enter the Player's FG%");
String FieldGoal=sc.nextLine();
System.out.println("Please enter the Player's 3P%");
String ThreePointer=sc.nextLine();
System.out.println("Please enter the Player's FT%");
String FreeThrow=sc.nextLine();
System.out.println("Please enter the Player's REB");
String Rebounds=sc.nextLine();
System.out.println("Please enter the Player's AST");
String Assists=sc.nextLine();
System.out.println("Please enter the Player's Points");
String Points=sc.nextLine();
String currentLine;
while((currentLine = Raptors.readLine()) != null) {
// trim newline when comparing with lineToRemove
String trimmedLine = currentLine.trim();
if(trimmedLine.equals(PlayerName+"," +FieldGoal+"," +ThreePointer+"," +FreeThrow+"," +Rebounds+"," +Assists+"," +Points)) continue;
output.write(currentLine + System.getProperty("line.separator"));
}
boolean successful = tempFile.renameTo(RaptorsFile);
output.close();
System.out.println("The CarsTemp file will have the new list");
options(Raptors,s);
I am having a problem i just want the user to input only player's name, for example if he inputs Kyle Lowry i want it to delete all of Kyle Lowry's stats. Below is sample of text field.
Lou Williams,41.1,36.3,87.6,60,53,508
Kyle Lowry,44.9,35.1,81.3,160,260,702
Patrick Patterson,48.8,46.0,75.0,177,61,286
Terrence Ross,42.9,38.7,87.9,119,30,411
Jonas Valanciunas,54.2,0.0,79.2,283,16,414