• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

duplicate file detection on hard-disk by java  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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
  • 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: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like an assignment/home work.
 
Sheriff
Posts: 21745
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Would the generation of a hash help here?
 
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • 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 count your weasels before they've popped. And now for a mulberry bush related tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!