客户端获取服务器端软件更新版本方法:

package com.platform.ui.update;

import java.io.BufferedInputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream; import javax.swing.filechooser.FileSystemView; import net.jimmc.jshortcut.JShellLink; import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane; public class DownloadFileController extends AnchorPane {
@FXML
private Button download; @FXML
void downloadFile() { // 获取资源路径
String tempResourcePath = this.getClass().getClassLoader()
.getResource("").getPath();
String resourcePath = tempResourcePath.substring(1,
tempResourcePath.indexOf("classes"))
+ "resource"; String targetPath = "C:\\f1"; File targetFile = new File(targetPath);
if (!targetFile.exists()) {
targetFile.mkdirs();
} File[] files = new File(resourcePath).listFiles(); for (File file : files) {
// File resourceFile = new File(resourcePath); // 以流的形式下载文件。
InputStream fis;
try {
fis = new BufferedInputStream(new FileInputStream(
file.getAbsolutePath()));
byte[] buffer = new byte[fis.available()];
fis.read(buffer);
fis.close();
FileOutputStream out = new FileOutputStream(targetFile + "\\"
+ file.getName());
out.write(buffer);
out.flush();
out.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// 创建写入的目标文件
String batPath = "C:\\f1\\run.bat";
File file = new File(batPath);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
// 写出流
BufferedWriter output;
try {
output = new BufferedWriter(new FileWriter(file));
output.write("cd C:\\f1");
output.write("\r\n");
output.write("javaws yk_platform_client.jnlp");
output.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} // 在桌面创建run.bat快捷方式
FileSystemView fsv = FileSystemView.getFileSystemView();
String writeFolderPath = fsv.getHomeDirectory().toString() + "\\"; // 这便是读取桌面路径的方法了
String jarFileName = "C:\\f1\\run.bat";// 建立快捷方式后鼠标放到上面的时候现实的文件所存位置
// create lnk file
JShellLink link = new JShellLink();
link.setFolder(writeFolderPath); // 创建的快捷方式所存在的位置,路径要真实路径,放到快速启动栏里面
link.setName("Amazon采集器更新文件"); // 快捷方式的名称
link.setIconLocation("C:\\f1\\erp.ico");// 图片位置
link.setPath(jarFileName);
link.setArguments("");// 设置执行参数
link.save(); System.out.println("执行完毕!");
} }

  

JavaFx客户端服务器C/S架构搭建的更多相关文章

  1. 【JavaFx】客户端服务器C/S架构搭建

    客户端获取服务器端软件更新版本方法: package com.platform.ui.update; import java.io.BufferedInputStream; import java.i ...

  2. 搭建QQ聊天通信的程序:(1)基于 networkcomms.net 创建一个WPF聊天客户端服务器应用程序 (1)

    搭建QQ聊天通信的程序:(1)基于 networkcomms.net 创建一个WPF聊天客户端服务器应用程序 原文地址(英文):http://www.networkcomms.net/creating ...

  3. MySQL1:客户端/服务器架构

    一.MySQL的客户端/服务器架构 前言 之前对MySQL的认知只限于会写些SQL,本篇算是笔记,记录和整理下自己对MySQL不熟悉的地方. 大致逻辑: MySQL的服务器程序直接和我们存储的数据打交 ...

  4. [网络编程之客户端/服务器架构,互联网通信协议,TCP协议]

    [网络编程之客户端/服务器架构,互联网通信协议,TCP协议] 引子 网络编程 客户端/服务器架构 互联网通信协议 互联网的本质就是一系列的网络协议 OSI七层协议 tcp/ip五层模型 客户端/服务器 ...

  5. 采用Serverless架构搭建Web应用

    本文会向你介绍一种新的可能,一种无服务器的方案来搭建Web应用.使用这个方案大部分运维方面的问题就不需要你自己操心了,而且也省去运行服务器的费用.本文从无服务的优势与限制两方面带您初识Serverle ...

  6. 【转载】Redis Sentinel 高可用服务架构搭建

    作者:田园里的蟋蟀 出处:http://www.cnblogs.com/xishuai/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接. 阅读 ...

  7. Apache web服务器(LAMP架构)

    1.apache介绍 1).世界上使用率最高的网站服务器,最高时可达70%:官方网站:apache.org 2).http 超文本协议 HTML 超文本标记语言 3).URL 统一资源定位符 http ...

  8. Nginx-LNMP架构搭建

    目录 Nginx-LNMP架构搭建 LNMP架构概述 LNMP架构环境部署 部署LNMP 部署博客Wordpress 搭建知乎产品wecenter 搭建edusoho (修改域名及安装路径) 数据库拆 ...

  9. lamp架构搭建

    目录 1. LAMP架构介绍 2.web服务器工作流程 2.1 cgi与fastcgi 2.2 httpd与php结合的方式 2.3 web工作流程 3. lamp平台搭建 3.1 安装httpd 3 ...

随机推荐

  1. 在Unity环境下使用抽象和接口

    http://gamasutra.com/blogs/VictorBarcelo/20131217/207204/Using_abstractions_and_interfaces_with_Unit ...

  2. ASP.NET 正则替换URL参数值

    public class HomeController : Controller { public ActionResult Index() { var url = "http://www. ...

  3. python学习之路 第二天

    1.import 导入模块 #!/usr/bin/python # -*- coding:utf-8 -*- import sys print(sys.argv) 2.字符串常用方法: 移除空白: s ...

  4. 【codeforces 148D】 Bag of mice

    http://codeforces.com/problemset/problem/148/D (题目链接) 题意 包中有w个白鼠,b个黑鼠.公主和龙轮流画老鼠,公主先画,谁先画到白鼠谁就赢.龙每画完一 ...

  5. 小尝试一下 cocos2d

    好奇 cocos2d 到底是怎样一个框架,正好有个项目需要一个游戏框架,所以稍微了解了一下.小结一下了解到的情况. 基本概念 首先呢,因为 cocos2d 是基于 pyglet 做的,你完全可以直接用 ...

  6. 最小生成树---Prim算法和Kruskal算法

    Prim算法 1.概览 普里姆算法(Prim算法),图论中的一种算法,可在加权连通图里搜索最小生成树.意即由此算法搜索到的边子集所构成的树中,不但包括了连通图里的所有顶点(英语:Vertex (gra ...

  7. CGI, FastCGI, WSGI, uWSGI, uwsgi简述

    CGI 通用网关接口(Common Gateway Interface/CGI)是一种重要的互联网技术,可以让一个客户端,从网页浏览器向执行在网络服务器上的程序请求数据.CGI描述了服务器和请求处理程 ...

  8. Linux之:Ubuntu速学笔记(1)

    撰写日期:2016-7-2 17:11:28 Saturday 课程资源:  web程序员角度ubuntu自修速学课程 链接来源:程序员在囧途, VMware: VMware Workstation1 ...

  9. chose.jquery 多选

    <select id="language" data-placeholder="选择类别..." class="chosen-select&qu ...

  10. 给zabbix穿一件漂亮的衣服

    推荐给zabbix穿上一件漂亮的衣服,安装Grafana推荐连接:http://www.myexception.cn/software-testing/2008870.html yum install ...