• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

duplicate file detection on hard-disk by java

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) please can anybody help me on HOW TO DETECT DUPLICATE FILE ON HARD-DISK USING JAVA LANGUAGE
... on the basis of contents of file

2) please help me over the concept & also provide the code for it
[ September 19, 2008: Message edited by: rajat mandaniyan ]
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by a duplicate file - a file with the same name or a file with the same name and same content ?

If the former you can use the File, FilenameFilter and FileFilter classes to list all the files in a directory with a given name.
If you need to check the content as well, then you need to look at the Java I/O tutorial.

Nobody here will just give you the code, you need to show some effort. Hava a look at the suggestions above and then see what you can come up with. If you have any problems show us what you have tried and give us full details of the problem.
See the HowToAskQuestionsOnJavaRanch FAQ for more details.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like an assignment/home work.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Joanne said, you will have to compare the full contents. However, you can use the file length() first as a shortcircuit check - if the lengths are different, the files most certainly are.
 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would the generation of a hash help here?
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gamini Sirisena:
Would the generation of a hash help here?



That is the normal way to do it. Checking lengths, etc. is not going to tell anything.

Run it through MD5 of sha1, store the result in a HashMap, and you are all set.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic