JAVA实现保存到桌面
1、了解.url文件内容
[DEFAULT]
BASEURL=
[InternetShortcut]
URL=
WorkingDirectory=
ShowCommand=
IconIndex=
IconFile=
Modified=
HotKey=
2、java实现
String rid = req.getParameter("rid"); String idIndex = rid.substring(1,2); String contIndex = rid.substring(2,3); String roomId = rid.substring(2+Integer.valueOf(idIndex),2+Integer.valueOf(idIndex)+Integer.valueOf(contIndex)); Map rinfo = vs.getRoomInfo(roomId); String shortInfo = "[InternetShortcut]\n"; shortInfo+="URL="+req.getScheme()+"://"+req.getServerName()+":"+req.getServerPort()+req.getContextPath()+"/servlet/VadioAction?ac=iroom&rid="+rid+"\n"; shortInfo+="IconIndex=1\n IconFile=http://www.rainheng.com/"+rinfo.get("img")+" \n"; shortInfo+=" IDList=[{000214A0-0000-0000-C000-000000000046}]\n Prop3=19,2"; resp.setHeader("Content-type", "application/octet-stream"); resp.setHeader("Content-Disposition", "attachment; filename="+URLEncoder.encode((String)rinfo.get("cname"),"UTF-8")+".url;"); resp.getOutputStream().write(shortInfo.getBytes());
shortInfo的拼装内容为 构建.url内的内容
URLEncoder.encode((String)rinfo.get("cname"),"UTF-8") 解决中文乱码
IconIndex 和 IconFile指定了 图标
标题:JAVA实现保存到桌面
作者:hugh0524
地址:https://blog.uproject.cn/articles/2016/07/22/1469203007374.html
0 0