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

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. [LeetCode] Combination Sum 组合之和

    Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C wher ...

  2. phpstorm 无法格式化代码

    phpstorm 默认的格式化代码的快捷键是 Ctrl + Alt + L,但是按了没有反应. 原因是当时开着网易云音乐,占用了这个快捷键,关了就好了.另外其他的程序比如QQ也有可能占用这个快捷键.

  3. 结构体内嵌函数指针实现C语言面向对象

    结构体内嵌函数指针 #include<stdio.h> void say(int age) { printf("我%d岁了\n",age); } struct stud ...

  4. Redis的三种启动方式

    转载:http://www.tuicool.com/articles/aQbQ3u Part I. 直接启动 下载 官网下载 安装 tar zxvf redis-2.8.9.tar.gz cd red ...

  5. Connect to Office365

    How to connect to office365 1. Connect to Exchange Online $UserCredential = Get-Credential $Session ...

  6. 测试ajax发送数据时在控制台看不到请求信息

    都是因为我把alert(xmlhttp);alert(url);打印测试数据放到了xmlhttp.open("GET",url,true);之前,导致后面的发送请求不执行了!

  7. PHPstorm同步文件时与ftp断开连接

    一用PHPstorm同步对比服务器端和本地文件的差异时,一会就断开ftp再也连不上了,弄了好久终于找到原因了,好像这个同步会频繁请求建立连接,服务器本地安全策略屏蔽了ip,还是下载后再做修改或者直接在 ...

  8. winform开发 总结1>winform程序使用线程的必要性,以及正确的使用方式

    winform程序中使用线程的必要性: 单线程操作在执行耗时任务时会造成界面假死,带来非常差劲的用户体验,有时候甚至会影响到正常的业务执行,使用多线程做相关操作实属不得已之举. 那么在编写程序之前必须 ...

  9. Codeforces Round #384 (Div. 2) B. Chloe and the sequence(规律题)

    传送门 Description Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems ...

  10. Manage Metadata Service Error: There are no addresses available for this application

    打开正常创建的Metadata Service后发现了如下的错误: 检查了Application Pool和Managed Metadata Web  Service ,发现两者一切正常,之后查看Sh ...