我正在获得"太多级别的符号链接"我正在使用Java NIO2: - 这是在Unix上运行的。任何想法都会有很大的帮助。感谢。
深入调用我正在调用的代码
Path currentFolder = Paths.get(currentFolder, date);
并且在流程的某个时刻 - 我正在尝试获取当前文件夹,如下面的方法..
public Path getNewFolder() {
return currentFolder.resolve("test").resolve("new");
//where "test" and "new" contains date in between the path. example currentFolder path: "/base/test/2014106/new"
}
但是我得到了异常......
java.nio.file.FileSystemException: /base/test/2014106/new: Too many levels of symbolic links
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91)
at sun.nio.fs.UnixException.asIOException(UnixException.java:111)
at sun.nio.fs.UnixDirectoryStream$UnixDirectoryIterator.readNextEntry(UnixDirectoryStream.java:171)
at sun.nio.fs.UnixDirectoryStream$UnixDirectoryIterator.hasNext(UnixDirectoryStream.java:201)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:198)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:69)
at java.nio.file.Files.walkFileTree(Files.java:2591)
at java.nio.file.Files.walkFileTree(Files.java:2624)
答案 0 :(得分:1)
当你有符号链接循环时,通常会发生这种情况。
例如,如果您执行ln -s . here
,则该目录将具有指向其父目录的子目录here
。这意味着你可以永久地递归它:
$ pwd
/home/me
$ ls -ld here
lrwxrwxrwx 1 me users 1 Apr 16 16:18 here -> .
$ cd here
$ pwd
/home/me/here
$ cd here/here/here/here/here/here/here
$ pwd
/home/me/here/here/here/here/here/here/here/here
由于您的堆栈跟踪被截断,因此很难确切地告诉您应该如何处理它。选项包括: