Links, Symbolic or Otherwise
Links, Symbolic or Otherwise
Creating a Symbolic Link
CreateSymbolicLink.java
import java.io.*;
import java.nio.file.*;
public class CreateSymbolicLink {
public static void main(String[] args) {
Path newLink = Paths.get("test-link");
Path target = Paths.get("Format.java");
try {
Files.createSymbolicLink(newLink, target);
} catch (IOException x) {
System.err.println(x);
}
}
}
Creating a Hard Link
CreateHardLink.java
import java.io.*;
import java.nio.file.*;
public class CreateHardLink {
public static void main(String[] args) {
Path newLink = Paths.get("hard-link");
Path existingFile = Paths.get("Format.java");
try {
Files.createLink(newLink, existingFile);
} catch (IOException x) {
System.err.println(x);
}
}
}
Detecting a Symbolic Link
TestSymbolicLink.java
import java.nio.file.*;
public class TestSymbolicLink {
public static void main(String[] args) {
Path file = Paths.get("test-link");
if (Files.isSymbolicLink(file)) {
System.out.println("I am symbolic link!");
} else {
System.out.println("guess wrong!");
}
}
}
Finding the Target of a Link
FindTarget.java
import java.io.*;
import java.nio.file.*;
public class FindTarget {
public static void main(String[] args) {
Path link = Paths.get("test-link");
try {
System.out.format("Target of link '%s' is '%s'%n", link, Files.readSymbolicLink(link));
} catch (IOException x) {
System.err.println(x);
}
}
}
相關文章
- 解決 ln -s 軟連結產生的Too many levels of symbolic links錯誤Symbol
- 2.3.2.2.1 Metadata Links
- Symbolic Discovery of Optimization AlgorithmsSymbolGo
- 2.1.3.2 Metadata and Data Links
- Html language common symbolic entitiesHTMLSymbol
- linux symbolic link attack tutorialLinuxSymbol
- css23 CSS Links, CursorsCSS
- Symbolic Link漏洞簡單背景介紹Symbol
- 演算法學習-Dancing Links X演算法
- /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic linkSymbol
- [20200309]rlwrap: error: Cannot execute sqlplus: Too many levels of symbolic linErrorSQLSymbol
- mybatis的 choose -- when test -- otherwise 標籤和 if test 標籤的區別MyBatis
- 論文閱讀:《Probabilistic Neural-symbolic Models for Interpretable Visual Question Answering》Symbol
- 《Predict Anchor Links across Social Networks via an Embedding Approach》閱讀筆記ROSAPP筆記
- Oracle 19C RAC open_links_per_instance引數問題Oracle
- 編譯opencv 提示opencv_sfm links to target absl::log but not found解決辦法編譯OpenCV
- 聽Wi-Fi之父Cees Links細話新一代無線技術
- 易優CMS模板標籤links友情連結控制友情連結的開啟方式
- 132年未解開的李雅普諾夫函式謎題,被Symbolic Transformer攻克了函式SymbolORM
- 瀏覽器中喚起native app || 跳轉到應用商城下載(二) 之universal links瀏覽器APP