JavaFx客户端服务器C/S架构搭建
客户端获取服务器端软件更新版本方法:
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架构搭建的更多相关文章
- 【JavaFx】客户端服务器C/S架构搭建
客户端获取服务器端软件更新版本方法: package com.platform.ui.update; import java.io.BufferedInputStream; import java.i ...
- 搭建QQ聊天通信的程序:(1)基于 networkcomms.net 创建一个WPF聊天客户端服务器应用程序 (1)
搭建QQ聊天通信的程序:(1)基于 networkcomms.net 创建一个WPF聊天客户端服务器应用程序 原文地址(英文):http://www.networkcomms.net/creating ...
- MySQL1:客户端/服务器架构
一.MySQL的客户端/服务器架构 前言 之前对MySQL的认知只限于会写些SQL,本篇算是笔记,记录和整理下自己对MySQL不熟悉的地方. 大致逻辑: MySQL的服务器程序直接和我们存储的数据打交 ...
- [网络编程之客户端/服务器架构,互联网通信协议,TCP协议]
[网络编程之客户端/服务器架构,互联网通信协议,TCP协议] 引子 网络编程 客户端/服务器架构 互联网通信协议 互联网的本质就是一系列的网络协议 OSI七层协议 tcp/ip五层模型 客户端/服务器 ...
- 采用Serverless架构搭建Web应用
本文会向你介绍一种新的可能,一种无服务器的方案来搭建Web应用.使用这个方案大部分运维方面的问题就不需要你自己操心了,而且也省去运行服务器的费用.本文从无服务的优势与限制两方面带您初识Serverle ...
- 【转载】Redis Sentinel 高可用服务架构搭建
作者:田园里的蟋蟀 出处:http://www.cnblogs.com/xishuai/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接. 阅读 ...
- Apache web服务器(LAMP架构)
1.apache介绍 1).世界上使用率最高的网站服务器,最高时可达70%:官方网站:apache.org 2).http 超文本协议 HTML 超文本标记语言 3).URL 统一资源定位符 http ...
- Nginx-LNMP架构搭建
目录 Nginx-LNMP架构搭建 LNMP架构概述 LNMP架构环境部署 部署LNMP 部署博客Wordpress 搭建知乎产品wecenter 搭建edusoho (修改域名及安装路径) 数据库拆 ...
- lamp架构搭建
目录 1. LAMP架构介绍 2.web服务器工作流程 2.1 cgi与fastcgi 2.2 httpd与php结合的方式 2.3 web工作流程 3. lamp平台搭建 3.1 安装httpd 3 ...
随机推荐
- 【swift学习笔记】六.访facebook登录页面
代码最下边有下载地址. 做这个demo的主要心得就是自适应所有的屏幕,要先布局大的框架,再一步一步设置小的细节. 看一下效果 再看一下自动适应所有屏幕的效果: keyboard打开时整个frame上移 ...
- Linux 中 SVN 重启关闭
a.启动SVN svnserve -d -r /A/B/svn/ 其中 -d 表示守护进程, -r 表示在后台执行 /A/B/svn/ 为svn的安装目录 b.关闭SVN 这里采取linux杀死进程的 ...
- 腾讯 auth_token
auth_token 从cookies里取出supertoken=2881515311; function auth_token(str) { var hash = 0; for (var i = 0 ...
- sql server多重行列转置的优化
将表1转化成表2: 表1 表2 得到表2的结果,需要经过多次pivot转换,再经union连接到一起,代码如下: ] from ( select 'a' as type, * from Table_1 ...
- Python实战项目网络爬虫 之 爬取小说吧小说正文
本次实战项目适合,有一定Python语法知识的小白学员.本人也是根据一些网上的资料,自己摸索编写的内容.有不明白的童鞋,欢迎提问. 目的:爬取百度小说吧中的原创小说<猎奇师>部分小说内容 ...
- Leetcode 45. Jump Game II
Given an array of non-negative integers, you are initially positioned at the first index of the arra ...
- leetcode
Coding on LeetCode Online Judge leetcode(leetcode website) Problems algorithms 13. Roman to Integer ...
- linux安装tomcat
一.下载tomcat 最新地址在:http://tomcat.apache.org 我下载的是:apache-tomcat-7.0.73.tar.gz,是已经编译好的包 解压文件后,移动到" ...
- JavaScript中让Html页面中循环播放文字
JavaScript中让Html页面中循环播放文字 <html> <head> <meta http-equiv="Content-Type" con ...
- sql杀死进程
查询SQL所有的链接 并可以查看连接当前正在做什么操作..使用的什么语句.. SELECT spid, blocked, DB_NAME(sp.dbid) AS DBName, program_na ...