I need to design a gui that will find out all the dead symbolic link from the directories. And I used the logic and syntax I find out in java orcle docs. And If I will give the direct path name of the symbolic file then it is running fine with the output and enable to find the smbolic link is active or not. Now the real problem is that , I want that logic of detection should run out through the complete files and subdirectories of the directory. So Then I used the tree walk concept to transver through the complete file system of the directory and embed the logic of the detection inside it for detection of the dead symbolic link. But now it showing erroe which is not approacable for me. I am new to java and īThis is my first project in java please help me. i will be greatful to you
import java.io.File; import java.io.IOException; import java.io.PrintStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class To_Transver { public void walk( String path ) { File root = new File( path ); File[] list = root.listFiles(); if (list == null) return; for ( File f : list ) { Path link; String k k = f.getAbsolutePath(); link=Paths.get(k); try { PrintStream format; format = System.out.format("Target of link" + " '%s' is '%s'%n", link, Files.readSymbolicLink(link); } catch (IOException x) { System.err.println(x); } } } public static void main(String[] args) { To_Transver fw = new To_Transver(); fw.walk("C:\\" ); } }
Error:java.nio.file.FileSystemException: Incorrect function.