关于java创建桌面快捷方式

场景:工程部署在 192.123.4.15 这台机器上面。我通过
FileSystemView fsv = FileSystemView.getFileSystemView();

String upurl = fsv.getHomeDirectory().toString();

System.out.println(upurl);

String filename = upurl + "/" + realfilename;

File myfile = new File(filename);

if(!myfile.exists()){

FileOutputStream fileoutputstream = new FileOutputStream(filename);//建立文件输出流

byte tag_bytes[] = templateContent.getBytes();

fileoutputstream.write(tag_bytes);

fileoutputstream.close();

}

    去创建一个桌面快捷方式。但是现在创建的快捷方式在 192.123.4.15这台机器上,而不是在我本机桌面上,我要怎么做才能创建到自己桌面上呢

java创建桌面快捷方式

原文地址来源于:点击打开链接

Insert title here

<%

String templateContent = "[InternetShortcut]" + "\n" + "URL=http://admin.weiscloud.com/";

String realfilename......
答案就在这里:java创建桌面快捷方式
----------------------Hi,地球人,我是问答机器人小S,上面的内容就是我狂拽酷炫叼炸天的答案,除了赞同,你还有别的选择吗?

你的代码运行在192.123.4.15上,FileSystemView.getFileSystemView();获取的是这台机器的文件系统,而不是你本地的。
这是路径的问题,你需要让192.123.4.15这台机器可以访问你的桌面并且拥有创建文件的权限,然后要把路径指定为该机器访问你的桌面的路径。
不如在本地开一个Service,远程机器需要创建快捷方式的时候把远程url传递到你指定的端口上,由本地来创建快捷方式。

/** * 创建答题卡 * * @param path * @param desFile * @param title * @param questionItems * @return * @throws Exception */ public static boolean createAnswerCardImage(String path, String desFile, String title, List questionItems) throws Exception { Mat img = Imgcodecs.imread(path); //绘制整体边框线 Imgproc.line(img, new Point(50, 50), new Point(2430, 50), new Scalar(0, 0, 0), 1); Imgproc.line(img, new Point(50, 50), new Point(50, 3458), new Scalar(0, 0, 0), 1); Imgproc.line(img, new Point(2430, 50), new Point(2430, 3458), new Scalar(0, 0, 0), 1); Imgproc.line(img, new Point(50, 3458), new Point(2430, 3458), new Scalar(0, 0, 0), 1); //绘制内容下边框 Imgproc.line(img, new Point(50, 900), new Point(2430, 900), new Scalar(0, 0, 0), 1); //绘制答案及选项 int rowNum = (questionItems.size() % 20 == 0) ? (questionItems.size() / 20) : (questionItems.size() / 20) + 1; int y = 1000; for (int i = 0; i < rowNum; i++) { int x = 60; int opti…