> pls help........
>
> how can i start doing comparison of two files that
> are in same folder.
Define what you mean by "start doing comparison."
> and how can i create two with different types.
> example a file with extension name of .doc and .txt
> pls.................
File f2 = new File("file.doc");
File f1 = new File("file.txt");
f1.createNewFile();
f2.createNewFile);
There, I've created a file with a .doc extension and one with a .txt extension.
Note that the notion of file "type" being related to the filename extension is simply a matter of convention--the various apps that open files assume that if a file has a .doc extension then it's a Word doc, but there's no magic in the file system to make that happen. I can write plain text out to a .doc file, write Word format out to a .txt file, and write a Java class file out to a .html fle.
If you want to create a Word document--that is a file whose contents are in Word format--the extension has nothing to do with that. You'll need to google for a library that will do that for you. However, since you asked this question in the first place, I suspect using such a library might be beyond you current skill level.
this is really the problem.
we have a machine problem wherein the application should be able to compare all the files in the folders/subfolders of both locations.
it should display all the name of the ff:
files that have the same name and same content
and files that have the same name but have the same
content.
i dont really know how can i start this one.
do i have to create a file with different extension but how can i compare them if they have different or same content?
plss help.
thanks
> do i have to create a file with different extension
Um, why would you be creating files? I thought you're comparing existing files.
> but how can i compare them if they have different or
> same content?
Open the files up. Read their contents into byte buffers of a couple k or tens of k in size, in a loop. Compare the contents of the byte buffers. If you find a difference, the files are different. If you get all the way through with no difference, they're the same.
You're going to have to spend some time learning about Java I/O. That means reading some tutorials, examples, etc. and writing tiny litlte programs just to make sure you understand.
Start here:
http://java.sun.com/docs/books/tutorial/essential/io/index.html
> we have a machine problem wherein the application
> should be able to compare all the files in the
> folders/subfolders of both locations.
>
>it should display all the name of the ff:
> files that have the same name and
> same content
> and files that have the
> same name but have the same
> content.
I really don't understand these requirements. Making sure that you do and getting them spelled out clearly and precisely is the first step.