This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I'm writing a tool which (among other things) needs to determine if two text files are different and, if different, which line has changed. Does anyone know of a tool or an API which I can code to which has this sort of functionality? Thanks, Joe
BJ Grau
Ranch Hand
Joined: Jul 10, 2001
Posts: 234
posted
0
Just use the io package. Do something like this to read your files: File f = new File("c:\\file.txt"); FileReader fr = new FileReader(f); LineNumberReader lnr = new LineNumberReader(fr); String lineText = ""; int lineNumber = 0; while(text != null) { line = lnr.getLineNumber(); text = lnr.readLine(); } This bit of code should read a file and grab each line, putting it into a String. Just do this to the two files you are interested in, and do a .equals between each line you read in. Hope this helps.
BJ Grau
Ranch Hand
Joined: Jul 10, 2001
Posts: 234
posted
0
Oops! An error in my code: line = lnr.getLineNumber(); text = lnr.readLine(); should read lineNumber = lnr.getLineNumber(); lineText = lnr.readLine();