• java创建快捷方式


    1. package com.ts.util.ex.project;  
    2.   
    3. import net.jimmc.jshortcut.JShellLink;  
    4.   
    5. /** 
    6.  * 快捷方式工具类 
    7.  *  
    8.  * @author ice(古雨QQ:494174519,13728989948(你的代码改进,是对我们共同的鼓励)) 
    9.  *  
    10.  */  
    11. public class ShortCut {  
    12.   
    13.     // 需要先下载jshortcut.jar直接在百度搜一下  
    14.     public static void main(String args[]) {  
    15.         String fileFolderPath = "D:\test\jshortcut-0_4.jar";  
    16.         String writeFolderPath = "D:\new";  
    17.         createShortCut(fileFolderPath, writeFolderPath);  
    18.         String path=getShortCutRealPath(writeFolderPath);  
    19.         System.out.println(path);  
    20.     }  
    21.   
    22.     /** 
    23.      * 创建一个快捷方式 
    24.      *  
    25.      * @param fileOrFolderPath 
    26.      *            源文件夹路径 
    27.      * @param writeShortCutPath 
    28.      *            目标文件路径(快捷方式型) 
    29.      */  
    30.     public static void createShortCut(String fileOrFolderPath,String writeShortCutPath) {  
    31.         JShellLink link = new JShellLink();  
    32.         writeShortCutPath.replaceAll("/", "\");  
    33.         String folder = writeShortCutPath.substring(0, writeShortCutPath.lastIndexOf("\"));  
    34.         String name = writeShortCutPath.substring(writeShortCutPath.lastIndexOf("\") + 1, writeShortCutPath.length());  
    35.         link.setName(name);// 目的快捷方式文件夹名称  
    36.         link.setFolder(folder);// 目的快捷方式文件路径片段  
    37.         link.setPath(fileOrFolderPath);  
    38.         link.save();  
    39.     }  
    40.   
    41.     /** 
    42.      * 获取一个快捷方式真实地址 
    43.      *  
    44.      * @param fileFolderPath 
    45.      *            源文件夹路径 
    46.      */  
    47.     public static String getShortCutRealPath(String fileFolderPath) {  
    48.         // 根据快捷方式的路径和文件夹名,获取源文件夹地址  
    49.         fileFolderPath.replaceAll("/", "\");  
    50.         String folder = fileFolderPath.substring(0, fileFolderPath.lastIndexOf("\"));  
    51.         String name = fileFolderPath.substring(fileFolderPath.lastIndexOf("\") + 1, fileFolderPath.length());  
    52.         JShellLink link = new JShellLink(folder, name);  
    53.         link.load();  
    54.         return link.getPath();  
    55.     }  
  • 相关阅读:
    [转]为iPhone4S和iOS5增加全局英汉词典教程
    Notes on MSBuild
    Using jQuery To Manipulate and Filter Data
    使用MSBuild进行自动化构建
    使用ADO.NET的计算列
    来自Twitter的前端工具包——Bootstrap
    Jquery Templetes简介
    C#导入导出Excel
    Mysql在sql中截取时间类型字段的年月日和时间
    使用NPOI导出Excel,并在Excel指定单元格插入图片
  • 原文地址:https://www.cnblogs.com/Logic09/p/4062588.html
Copyright © 2020-2023  润新知