Here you can find the source of createSymbolicLink(File pTargetFile, File pLink)
Parameter | Description |
---|---|
pTargetFile | The file the link will point to. |
pLink | The link location. |
Parameter | Description |
---|---|
IOException | if linking fails. |
public static void createSymbolicLink(File pTargetFile, File pLink) throws IOException
//package com.java2s; /**/*from ww w .j a va2 s . c o m*/ * Copyright (C) 2014 Karlsruhe Institute of Technology * * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Main { /** * Wrapper for creating a symbolic link using java.nio * * @param pTargetFile The file the link will point to. * @param pLink The link location. * * @throws IOException if linking fails. */ public static void createSymbolicLink(File pTargetFile, File pLink) throws IOException { Path target = Paths.get(pTargetFile.toURI()); Path link = Paths.get(pLink.toURI()); Files.createSymbolicLink(link, target); } }