集册 Java实例教程 CurreleLink方法创建对现有文件的硬链接

CurreleLink方法创建对现有文件的硬链接

欢马劈雪     最近更新时间:2020-01-02 10:19:05

421
CreateLink方法创建到现有文件的硬链接

import java.io.IOException;

import java.nio.file.Files;
/**
 from
* n o w j a v a . c o m - 时代Java 
**/

import java.nio.file.Path;

import java.nio.file.Paths;


public class Main {

  public static void main(String[] args) throws Exception {

    try {

      Path targetFile = Paths.get("C:/home/docs/users.txt");

      Path linkFile = Paths.get("C:/home/music/users.txt");

      Files.createLink(linkFile, targetFile);

展开阅读全文