GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes access contents of Shortcut + java File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "access contents of Shortcut + java File" Watch "access contents of Shortcut + java File" New topic
Author

access contents of Shortcut + java File

madhup narain
Ranch Hand

Joined: Dec 14, 2004
Posts: 148
hi,

I want to access

FOLDER
|_ File1
|_ File2
|_ Shortucut to some folder


Problem... how can i access the files in the Shortcut.

Regards


Money for nothing and Java for Free
SCJP, SCWCD
madhup narain
Ranch Hand

Joined: Dec 14, 2004
Posts: 148
still no solutions... ?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

You can't really do it from pure Java. The file format is undocumented. People have reverse engineered parts of it, but I believe (and my memory may be wrong) that you can't really use the information therein from Java; you need to make Win32 calls -- i.e., JNI, Java native methods -- to use it.

The bloody JFileChooser didn't even support shortcuts until Tiger!


[Jess in Action][AskingGoodQuestions]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

As Ernest pointed out, this seems specific to the operating system.

I did some experimenting with a folder alias on my Mac, and couldn't find a way in Java to get much out of it. (Represented as a File object, the alias appears to be a file rather than a directory, but the length is zero.)


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
madhup narain
Ranch Hand

Joined: Dec 14, 2004
Posts: 148
thanks guys,

For clearing alot of thoughts, i had be scanning the API to find a suitable method. anyways that gives me my answer.

SUN should provide a method that returns the Target location of a file object.Which means that in case where its a directory it just provides the absolute path ot it and in case its a shortcut it provides an absolute path to the location of the dir. Just a thought.

Regards
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
In Linux these are called links, although there are two different kinds: hard links and symbolic links. Since all files have at least one hard link, they don'g cause any problems. A symbolic link to a directory behaves exactly the same as an actual directory as far as the File class is concerned. I'm not sure about symbolic links to other types of files, but I think they behave the same as well. Most likely this has nothing to do with Java or the File class but is handled at the OS level in such a way that File is quite seamless. Unfortunately, not all operating systems are smart enough to handle files so well.

Layne


Java API Documentation
The Java Tutorial
 
GeeCON Prague 2014
 
subject: access contents of Shortcut + java File