【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 ...
随机推荐
- putty简单使用
一.Putty简介 Putty是一款轻便的远程登录工具,用它可以非常方便的登录到Linux服务器上进行各种操作(命令行方式).Putty完全免费,而且无需安装(双击即可运行),支持多种连接类型(Tel ...
- SlackWare安装
Keep It Simple Stupid 01.下载 slackware: http://www.slackware.com/ 中科大: http://mirrors.ustc.edu.cn ...
- MySQL中分组取第一条, 以及删除多余的重复记录
检查重复记录 -- 检查重复code1 select count(identity) num, identity from event_log where code='code1' order by ...
- TouchID 指纹解锁
概述 TouchID 指纹解锁 详细 代码下载:http://www.demodashi.com/demo/10701.html 一.软硬件支持 指纹验证功能的最低硬件支持为iPhone5s, iPa ...
- leetcode679:24Game
题目链接 考虑1,5,5,5这种情况,有:5*(5-1/5)=24所以除法必须自定义运算才行. class Num: def __init__(self,up,down=1): self.up=up ...
- 使用EditPlus技巧,提高工作效率(附英文版、自动完成文件、语法文件下载)
http://www.cnblogs.com/JustinYoung/archive/2008/01/14/editplus-skills.html
- javascript高级程序设计第二章
看后总结: 1.js代码用得最多的两种加载方式: a)外部文件形式:<script type="text/javascript" src="jquery.min.j ...
- Google Map 学习过程中的代码
<!DOCTYPE html><html> <head> <title>Simple click event</title> <met ...
- Java编程性能优化一些事儿【转】
原文出处: 陶邦仁 在JAVA程序中,性能问题的大部分原因并不在于JAVA语言,而是程序本身.养成良好的编码习惯非常重要,能够显著地提升程序性能. 1. 尽量在合适的场合使用单例 使用单例可以减轻加载 ...
- android使用JsonWriter拼json字符串
JsonWriter使用 Example: 拼一个如下的json格式String { [ { "id": 912345678901, ...