Results 1 to 3 of 3
  1. #1
    jvh
    jvh is offline Member
    Join Date
    Feb 2010
    Location
    Cuba
    Posts
    2
    Rep Power
    0

    Question Skipping links!!!

    Hi everyone!!!

    I'm developing an recursive algorithm to search for files. Everything works fine until my program gets into a link(I mean to Linux symbolic links) which is pointing toward a folder. This link is located in a sub-folder of the folder to which has been linked, so it's generating an endless loop. Well, how to solve this?

    I have made this other times, but using c/c++. In those case I just simply tell to my algorithm:

    "Skip the links and goes ahead."

    ...but how can I get the same using Java?

    I was looking for something with the same behavior of isDirectory(), maybe something like isLink()... but I get my hands empty.

    I hope somebody help me with a link, an example, a clue or whatever.

    Thanks in advance... :rolleyes:

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You can use
    Java Code:
    Attributes.readBasicFileAttributes(file, LinkOption.NOFOLLOW_LINKS).isSymbolicLink();
    where file is a java.nio.file.Path object.
    Reading the API specs for those java.nio classes will make things clearer.

  3. #3
    jvh
    jvh is offline Member
    Join Date
    Feb 2010
    Location
    Cuba
    Posts
    2
    Rep Power
    0

    Default Nothing yet!!!

    Hi

    I've been all this time trying to get working the recursion of my algorithm using the help of "r035198x" but I receive several errors when I compile.

    Well, the source of those errors was simply that "java.nio.file" is implemented in the JDK7(the next major release of the Java™ SE Platform) and the version that I've installed is the JDK6.

    ...so how can I get the same using the JDK6?

    I believe there have to be some way to get it work. I can't imagine that all developers have to wait until the next version of JDK to do something like what I'm doing.

    Thanks in advance.

Similar Threads

  1. Skipping lines during debugging
    By Taxi in forum New To Java
    Replies: 5
    Last Post: 04-01-2014, 04:03 PM
  2. Finding web links
    By ishdevil in forum New To Java
    Replies: 2
    Last Post: 02-11-2010, 11:42 AM
  3. links between variables
    By Keerti in forum New To Java
    Replies: 2
    Last Post: 08-12-2008, 03:07 PM
  4. skipping input
    By windie_86 in forum New To Java
    Replies: 1
    Last Post: 02-12-2008, 07:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •