package cn.itbaizhan.health.util;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
import javax.jms.BytesMessage;
public class FileOperation {
/**
* getSavePath() + "\\"+ getUploadFileName()
* 文件copy到服务器
* @throws IOException
*/
public static void Dec_COPY_FILE(String filePath, String source) {
FileOutputStream fos = null;
FileInputStream fis = null;
try {
fos = new FileOutputStream(filePath);// 建立文件输出流
fis = new FileInputStream(source);// 建立文件上传流
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
close(fos, fis);
}
}
/**
* 关闭FileOutputStream和FileInputStream
*
* @param fos
* @param fis
*/
private static void close(FileOutputStream fos, FileInputStream fis) {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
System.out.println("FileInputStream关闭失败");
e.printStackTrace();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
System.out.println("FileOutputStream关闭失败");
e.printStackTrace();
}
}
}
/**
* 逆向读取文件
*
* @param path
* @return
*/
public List<String> getFileReverse(String path) {
try {
// 下面是先写文件, 向文件尾追加, 若文件不存在则自动创建文件
byte[] bytes = new byte[0];
String rafread = "";
System.out.println("读取文件:" + path);
List<String> filelist = new ArrayList<String>();
FileWriter fw = new FileWriter(path, true); // 用FileWriter打开文件
PrintWriter pw = new PrintWriter(fw); // 用写指针加载文件
String[] str = { "" }; // 要写入的字符串
for (String index : str) {
pw.println(index); // 每次都向文件尾追加
}
pw.close(); // 关闭
fw.close(); // 关闭
// 下面定位文件末行, 一行一行向上读取
RandomAccessFile raf = new RandomAccessFile(path, "r"); // 该类可以定位文件,
// 是java
// IO类中唯一可以用来定位的
long len = raf.length(); // 获得文件的长度,以便定位末尾
if (len <= 3) { // 判断文件是否为空
System.out.println("the flie is NULL!");
return null;
}
long pos = len - 1; // 定位文件尾
int xy = 0;
String rd = "";
while ((rafread = raf.readLine()) != null) {
rd += rafread + "\n";
}
raf.seek(pos); // 最后还需要读取第一行
rd += raf.readLine();
System.out.println(rd);
filelist.add(rd);
raf.close(); // 关闭
return filelist;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.exit(0);
return null;
}
public String getMyFile(String path) {
try {
// 下面是先写文件, 向文件尾追加, 若文件不存在则自动创建文件
System.out.println("读取文件:" + path);
// 下面定位文件末行, 一行一行向上读取
RandomAccessFile raf = new RandomAccessFile(path, "r"); // 该类可以定位文件,
// 是java
// IO类中唯一可以用来定位的
long len = raf.length(); // 获得文件的长度,以便定位末尾
if (len == 0)
return null;
long pos = len - 1; // 定位文件尾
String abc = null;
while (pos > 0) { // 判断文件是否到达头
abc = raf.readLine();
break;
}
raf.seek(pos); // 最后还需要读取第一行
raf.close(); // 关闭
return abc;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.exit(0);
return null;
}
/**
* 顺序逐行写文件
*
* @param path
* @param filecontent
* @return
*/
public String writeFileSequence(String path, List<String> filecontent) {
String s = new String();
String s1 = new String();
try {
File f = new File(path);
if (!f.exists()) {
f.createNewFile();// 不存在则创建
} else {
f.delete();
f.createNewFile();
}
BufferedReader input = new BufferedReader(new FileReader(f));
while ((s = input.readLine()) != null) {
s1 += s;
}
input.close();
for (int i = 0; i < filecontent.size(); i++) {
if (filecontent.get(i) == null)
continue;
if (filecontent.get(i).trim().length() == 0)
continue;
s1 += filecontent.get(i);
}
BufferedWriter output = new BufferedWriter(new FileWriter(f));
output.write(s1);
output.close();
} catch (Exception e) {
e.printStackTrace();
}
return s1;
}
/**
* 写文件
*
* @param path
* @param filecontent
*/
public static void Dec_WRITE_FILE(String path, String filecontent) {
try {
File f = new File(path);
if (!f.exists()) {
f.createNewFile();// 不存在则创建
} else {
f.delete();
f.createNewFile();
}
BufferedWriter output = new BufferedWriter(new FileWriter(f));
output.write(filecontent);
output.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Healthy_manager.zip
共508个文件
gif:195个
class:62个
java:57个
需积分: 10 1 下载量 129 浏览量
2019-05-30
14:59:29
上传
评论
收藏 21.45MB ZIP 举报
温馨提示
javaEE健康管理系统主要功能包括:教师登录退出、教师饮食管理、教师健康日志、体检管理等等。本系统结构如下: (1)用户模块: 实现登录功能 实现用户登录的退出 实现用户注册 (2)教师饮食管理: 根据教师的相关信息,计算其每天所需热量,给出一周的推荐菜单。 (3)教师健康日志: 用户可以记录自己健康日记,记录每一天的睡眠,饮酒,吸烟,血压,体重等情况。 (4)教师体检管理: 教师可通过该平台查询每次的体检结果,显示部分项目随时间变化的曲线 (5)疾病预测评估: 针对糖尿病和高血压两种疾病,利用数学线性回归的方法,模拟计算出教师患病概率。 (6) 后台管理员模块 管理员用户登录功能:通过账号登录系统。 管理员管理教师功能:可以增删改查教师基本信息。 管理员管理体检结果:可以增删改查教师体检记录。 健康新闻管理:可以发布或删除、编辑新闻
资源推荐
资源详情
资源评论
收起资源包目录
Healthy_manager.zip (508个子文件)
ExamAction.class 6KB
FileOperation.class 5KB
ExcelReader.class 5KB
NoticeAction.class 5KB
NoticeBaseAction.class 5KB
Exam.class 4KB
Dairy.class 4KB
TeacherAction.class 3KB
ManagerAction.class 3KB
ExamBaseAction.class 3KB
Teacher.class 3KB
DairyAction.class 3KB
PageDAOImpl.class 2KB
Pages.class 2KB
TeacherDAOImpl.class 2KB
DairyBaseAction.class 2KB
NoticeDAOImpl.class 2KB
FoodDwr.class 2KB
ExamDAOImpl.class 2KB
ManagerDAOImpl.class 2KB
TeacherBaseAction.class 2KB
Food.class 2KB
Sick.class 2KB
PageServiceImpl.class 2KB
ManagerBaseAction.class 2KB
FoodServiceImpl.class 2KB
FoodDAOImpl.class 2KB
Active.class 2KB
Notice.class 2KB
PageDAOImpl$3.class 2KB
ExamDAOImpl$1.class 2KB
DairyDAOImpl.class 2KB
NoticeServiceImpl.class 2KB
PageDAOImpl$2.class 2KB
Manager.class 1KB
ExamServiceImpl.class 1KB
TeacherServiceImpl.class 1KB
PageDAOImpl$1.class 1KB
NoticeDAOImpl$1.class 1KB
ManagerServiceImpl.class 1KB
Ree.class 1KB
SickAction.class 1KB
DairyServiceImpl.class 1KB
SickBaseAction.class 1KB
FoodBaseAction.class 852B
Highcharts.class 844B
ExcelFinalString.class 825B
NoticeServiceInter.class 492B
NoticeDAOInter.class 480B
ExamServiceInter.class 473B
PageDAOInter.class 469B
ExamDAOInter.class 463B
FoodDAOInter.class 457B
TeacherDAOInter.class 454B
FoodAction.class 439B
TeacherServiceInter.class 428B
FoodServiceInter.class 404B
ManagerServiceInter.class 393B
ManagerDAOInter.class 381B
DairyServiceInter.class 351B
DairyDAOInter.class 339B
PageServiceInter.class 308B
.classpath 1KB
org.eclipse.wst.common.component 504B
org.eclipse.wst.jsdt.ui.superType.container 49B
default.css 21KB
style1.css 5KB
style.css 5KB
main.css 5KB
calendar.css 2KB
backmain.css 2KB
menu.css 1KB
prettify.css 973B
iframe.css 212B
static.gif 35KB
2.gif 25KB
1.gif 23KB
4.gif 21KB
3.gif 20KB
35.gif 13KB
42.gif 13KB
40.gif 10KB
18.gif 8KB
19.gif 8KB
11.gif 8KB
32.gif 7KB
49.gif 6KB
29.gif 6KB
97.gif 5KB
65.gif 5KB
d.gif 5KB
31.gif 5KB
46.gif 5KB
57.gif 5KB
b.gif 5KB
45.gif 5KB
8.gif 5KB
43.gif 4KB
33.gif 4KB
c.gif 4KB
共 508 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
温酒(๑‾᷅^‾᷅๑)
- 粉丝: 0
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功