DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    1

    Unhappy IOException error

    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???
    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)
    {}
    
      }
    
    
    }
    [ArchAngel added CODE tags]

  2. #2
    Join Date
    Mar 2003
    Posts
    834
    It's much more helpful if you post the full error message you're getting.
    ArchAngel.
    O:-)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links