zoukankan      html  css  js  c++  java
  • 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.     }  
  • 相关阅读:
    Spring Cloud Feign服务之间的调用
    jooq映射原理_JOOQ事实:从JPA批注到JOOQ表映射
    ORM优缺点详解,已经JOOQ、MyBatis介绍
    JOOQ 踩坑和评价
    ORM框架简介及优缺点
    在linux中查看jdk的版本以及安装路径
    青春未逝,热望长存—OI生涯回忆录
    耻辱柱
    浅谈如何应对考场上可能出现的烦人小学生
    RP测试器
  • 原文地址:https://www.cnblogs.com/Logic09/p/4062588.html
Copyright © 2011-2022 走看看