Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

Detecting Equivalence between Two Files

Thread view: 
kvnsmnsn@hotmail.com - 24 Jul 2006 16:41 GMT
When I'm in the "emacs" editor on a file in a directory, and have made
changes to that file that I haven't saved, and then open up a window
on a file in another directory that happens to be a symbolic link to
the file I had already been editing, "emacs" can tell that I've opened
another window on the same file, and therefore brings up another copy
of the buffer that I'd edited complete with all my unsaved changes to
it.

Is there some way to tell this in Java in general?  If I open one file
in a Java program, make changes to it, and then the user requests the
opening of a file with a different path name that happens to be the
same as the first file, can Java detect that it's the same file and
therefore not reopen it?

If anyone can point me to some information on this I'd greatly appre-
ciate it.

---Kevin Simonson

"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_
Papastefanos Serafeim - 24 Jul 2006 17:38 GMT
Well, I believe that emacs is doing that by checking if the file
being opened is a symbolic link with an already opened file...

To do that in java, you can probably use the method
getCanonicalPath() of the File class.

Signature

Papastefanos Serafeim
serafeim@otenet.gr

> When I'm in the "emacs" editor on a file in a directory, and have made
> changes to that file that I haven't saved, and then open up a window
[quoted text clipped - 18 lines]
> if you don't believe there's a way."
> from _Why Not_
kvnsmnsn@hotmail.com - 24 Jul 2006 21:05 GMT
Papastefanos Serafeim posted:

=Well, I believe that emacs is doing that by checking if the file
=being opened is a symbolic link with an already opened file...
=
=To do that in java, you can probably use the method
=getCanonicalPath() of the File class.

Thanks!  I was able to write a Java program using <getCanonicalPath()>
that recognized equivalences in files no matter what path name I spe-
cified.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.