Can someone help me about my system. Im having trouble about my code. I cant figure out how it works. Lets see. Soo its about File class. How am i be able to compare string to notepad data. I've tried this code:
import java.util.*; import java.io.*; import java.io.File; public class DeleteF { Scanner in = new Scanner(System.in); File file = new File("C:\\Documents and Settings\\user\\My Documents" + "\\NetBeansProjects\\StudentInformation\\src\\information.txt"); ArrayList store = new ArrayList(); String idM, record, id, temp; int match = 0; public void delete() throws Exception{ Scanner inFile = new Scanner(file); inFile.useDelimiter("#"); System.out.print("ID: "); idM = in.nextLine(); while(inFile.hasNext()){ record = inFile.nextLine(); // System.out.println(record); if(inFile.hasNext()){ inFile.nextLine(); if(idM.equals(inFile.next())){ System.out.println("LOL"); } else{ System.out.println("No records found!"); } } store.add(record); }//end of while for(int x = 0; x < store.size(); x++){ System.out.println(store.get(x)); } }//end of delete() }//end of DeleteF class
My problem is, the user should enter an existing ID. And when it matches to the ID from the notepad, it will be deleted ..
1.JPG