Results 1 to 3 of 3

Thread: Compare lists

  1. #1
    JavaNoob is offline Member
    Join Date
    Aug 2007
    Posts
    10
    Rep Power
    0

    Default Compare lists

    I figure if I give myself a little challenge every couple of days, eventually this JAVA stuff will start sinking in :)

    I'm working on a program that will compare two lists. For now I am trying to get familiar with JAVA altogether.

    I've written this code with the primary objective to get more familiar with fileWriter and fileReader. Basically, what I want it to do for the time being is to take my two arguments (which will be the name of the read file and the name of the write file), and have the readFile read the file at my first arguement and have writeFile write an arbitrary file that is named after my second argument.
    It compiles but does not like it when i run it with arguements
    ex:

    java listCompare ss.txt 1sttry.txt
    Exception in thread "main" java.lang.NoClassDefFoundError: ss/txt

    here's my code:

    Java Code:
    import java.io.*;
    public class listCompare
    {
    public static void main(String []args)
    {
    	
    //arguments that tells us what is being compared ot what
    String Base = args[0];
    String Compare = args[1];
    
    //read base file and load it to a string 
    try
    {
    FileReader baseFile = new FileReader(Base);
    BufferedReader buffer= new BufferedReader (baseFile);
    //String holdFile= baseFile;
    FileWriter newFile = new FileWriter(Compare);
    
    buffer.close();
    }
    catch (IOException e) { System.out.println(e);}
    }
    }
    Thanks
    JN
    Last edited by levent; 08-08-2007 at 12:01 AM.

  2. #2
    levent Guest

    Default

    Hi JavaNoob,

    That is a strange error. Can you rewrite your main method like this and try again:

    Java Code:
    public static void main(String[] args)
    By the way, please use [code] tag around your codes while posting. It will make your codes more readable!

  3. #3
    JavaNoob is offline Member
    Join Date
    Aug 2007
    Posts
    10
    Rep Power
    0

    Default

    Thanks! it worked great! Now to figure out the rest of what I am trying to do.


    JN

Similar Threads

  1. 2 dimensional Lists
    By gapper in forum New To Java
    Replies: 4
    Last Post: 01-20-2008, 10:01 AM
  2. question about linked lists
    By jkurth in forum Advanced Java
    Replies: 1
    Last Post: 11-11-2007, 09:33 AM
  3. Tudu Lists 2.1
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 08-10-2007, 05:39 PM
  4. how to compare 2 vector lists?
    By oregon in forum New To Java
    Replies: 2
    Last Post: 07-25-2007, 09:25 PM
  5. Tudu Lists 2.0
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 07-11-2007, 04:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •