集册 Java实例教程 创建硬链接

创建硬链接

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

1053
创建硬链接
import java.io.IOException;//时 代      J a v a   公   众 号 - nowjava.com 提 供

import java.nio.file.FileSystems;

import java.nio.file.Files;

import java.nio.file.Path;


/**

 

 */

public class HardLink {

    /*

    Create a hard link:

    Windows:

    mklink /H newlinkfolder targetfolder

    linux:

    ln  targetfolder newlinkfolder

     */

    public static void main(String[] args) {

        Path link = FileSystems.getDefault().getPath("D:/intro/new");

        Path target = FileSystems.getDefault().getPath("C:/Users");


        try {

            //Files.createLink

            Files.createLink(link, target);// from 时   代     Java  公  众  号 - nowjava.com

        } catch (IOException | UnsupportedOperationException e) {

            e.printStackTrace();

            
展开阅读全文