|
|
|
|
|
- package com.ts.util.ex.project;
-
- import net.jimmc.jshortcut.JShellLink;
-
- public class ShortCut {
-
-
- public static void main(String args[]) {
- String fileFolderPath = "D:\\test\\jshortcut-0_4.jar";
- String writeFolderPath = "D:\\new";
- createShortCut(fileFolderPath, writeFolderPath);
- String path=getShortCutRealPath(writeFolderPath);
- System.out.println(path);
- }
-
-
- public static void createShortCut(String fileOrFolderPath,String writeShortCutPath) {
- JShellLink link = new JShellLink();
- writeShortCutPath.replaceAll("/", "\\");
- String folder = writeShortCutPath.substring(0, writeShortCutPath.lastIndexOf("\\"));
- String name = writeShortCutPath.substring(writeShortCutPath.lastIndexOf("\\") + 1, writeShortCutPath.length());
- link.setName(name);
- link.setFolder(folder);
- link.setPath(fileOrFolderPath);
- link.save();
- }
-
-
- public static String getShortCutRealPath(String fileFolderPath) {
-
- fileFolderPath.replaceAll("/", "\\");
- String folder = fileFolderPath.substring(0, fileFolderPath.lastIndexOf("\\"));
- String name = fileFolderPath.substring(fileFolderPath.lastIndexOf("\\") + 1, fileFolderPath.length());
- JShellLink link = new JShellLink(folder, name);
- link.load();
- return link.getPath();
- }
- }
|
|