Я хочу создать символическую ссылку в RHEL 5 с помощью Java. В java6 createSymbolicLink есть только два параметра. Но в случае Java7 FileAttribute был включен вместе с параметрами, т. Е. В общей сложности три параметра.Symlink с Files.createSymbolicLink (Java 7) в RHEL 5
public static Path createSymbolicLink(Path link, Path target, FileAttribute... attrs) throws IOException Creates a symbolic link to a target (optional operation). The target parameter is the target of the link. It may be an absolute or relative path and may not exist. When the target is a relative path then file system operations on the resulting link are relative to the path of the link. The attrs parameter is optional attributes to set atomically when creating the link. Each attribute is identified by its name. If more than one attribute of the same name is included in the array then all but the last occurrence is ignored. Where symbolic links are supported, but the underlying FileStore does not support symbolic links, then this may fail with an IOException. Additionally, some operating systems may require that the Java virtual machine be started with implementation specific privileges to create symbolic links, in which case this method may throw IOException. Parameters: link - the path of the symbolic link to create target - the target of the symbolic link attrs - the array of attributes to set atomically when creating the symbolic link
Я не мог понять, что я должен здесь дать в качестве третьего параметра. Все, что мне нужно сделать, это создать символическую ссылку.
Проблема в том, что я не знаю, что я должен дать в третьем параметре, а также я не очень-то разбираюсь в интерфейсе FileAttribute
. Пожалуйста помоги.
Для Downvoters просьба прокомментировать причину для downvoting.
Как насчет третьего атрибута? – Maximin
Третий атрибут является необязательным и имеет смысл только на определенных платформах. Проверьте документацию на [Oracle] (http://docs.oracle.com/javase/tutorial/essential/io/links.html). В Java 6 вы связали «file1» с «file2», в Java 7 вы привязываете Paths.get («file1») к Paths.get («file2»). Попробуйте пример, который я вам дал. Оно работает. –