Please help,
i am new in java and i am trying to make a program that compares two string that it reads from two different files. if two letters are equal it increments the counter and writes the the total counter in another file. i dont know why it doesnt work. please any suggestions???
[ArchAngel added CODE tags]Code:import java.io.*; class Temp1{ public static void main(String[] args) { try{ check_Strings(); }catch(IOException ex){} } static void check_Strings() throws IOException { try{ FileWriter file = new FileWriter("/Teza/Perfundimi.txt"); PrintWriter fund = new PrintWriter(file); FileReader file1 = new FileReader("/Teza/temp.tmp"); FileReader file2 = new FileReader("/Teza/Teza1/Result.rst"); BufferedReader inputfile1 = new BufferedReader(file1); BufferedReader inputfile2 = new BufferedReader(file2); String one; String two; one = inputfile1.readLine().toString(); two = inputfile2.readLine().toString(); int counter = 0; int n = one.length(); int i; for (i = 0; i <= n - 1; i++) { if (one.charAt(i) == (two.charAt(i))) counter++; } fund.print(counter); fund.close(); inputfile1.close(); inputfile2.close(); }catch(IOException e) {} } }


Reply With Quote


Bookmarks