Results 1 to 3 of 3

Thread: Compare 2 files

  1. #1
    GTMPAL is offline Member
    Join Date
    Oct 2011
    Posts
    1
    Rep Power
    0

    Default Compare 2 files

    I would like to compare 2 files in Java. please send me the code snipt for this scenario:

    File1:
    ./divisions/Z7346/Z1111/0064C/123456/123456_aug11.pdf
    ./divisions/Z7346/Z3333/0064C/434234/345678_aug11.pdf
    ./divisions/Z7346/Z4444/0064C/343444/234567_aug11.pdf


    File2:
    ./divisions/Z7346/Z2260/0064C/123456/123456_aug11.pdf
    ./divisions/Z7346/Z2222/0064C/434234/345678_aug11.pdf
    ./divisions/Z7346/Z3333/0064C/343444/234567_aug11.pdf

    It needs to compare these files and print the diffrence by comparing the report name(234567_aug11.pdf,345678_aug11.pdf)
    Eg. Check if the report 345678_aug11.pdf is same in both file 1 and 2. The file name will normally be the last 16 characters of a line.
    Last edited by GTMPAL; 10-12-2011 at 06:24 PM.

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Compare 2 files

    Quote Originally Posted by GTMPAL View Post
    I would like to compare 2 files in Java. please send me the code snipt for this scenario:
    That is not how this works. You should not expect a stranger to do this for you, unpaid, in their spare time - it is your responsibility to complete. We can help you along the way, if you make an effort and ask a specific question.
    A library worth looking into: JLibDiff | Free Development software downloads at SourceForge.net
    Suggested reading: How to ask questions

  3. #3
    Join Date
    Jul 2011
    Posts
    30
    Rep Power
    0

    Default Re: Compare 2 files

    Quote Originally Posted by GTMPAL View Post
    The file name will normally be the last 16 characters of a line.
    To gain the file name this is all you need to do:
    Java Code:
    File file = new File("./divisions/Z7346/Z1111/0064C/068543051/123456_aug11.pdf");
    String fileName = file.getName();
    Regards Serb.

Similar Threads

  1. Compare 2 pdf files
    By kris_java in forum Advanced Java
    Replies: 9
    Last Post: 12-07-2012, 12:22 PM
  2. treeset compare
    By samaravadhi in forum New To Java
    Replies: 6
    Last Post: 09-07-2011, 03:59 PM
  3. How compare two String?
    By artemff in forum New To Java
    Replies: 8
    Last Post: 08-29-2011, 08:00 AM
  4. Compare 2 large files
    By bezudar in forum Advanced Java
    Replies: 3
    Last Post: 11-23-2008, 02:18 AM
  5. Compare 2 XML
    By Peter in forum XML
    Replies: 1
    Last Post: 07-05-2007, 02:58 AM

Posting Permissions

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