package com.zksoo.utils;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.List;
public class FileHelp {
private String LastError = "";
public boolean createFolder(String folderPath) {
boolean b = false;
try {
java.io.File myFilePath = new java.io.File(folderPath);
if (!myFilePath.exists()) {
b = myFilePath.mkdir();
}else{
b = true;
}
}catch (Exception e) {
LastError = "创建目录操作出错,错误信息="+e.getMessage();
}
return b;
}
public boolean createFolders(String paths){
boolean b = false;
try{
List<String> ls = new ArrayList<String>();
File f = new File(paths);
while(!f.exists()){
ls.add(f.getPath());
f = f.getParentFile();
if( f == null) break;
}
boolean iserror = false;
for(int i = (ls.size()-1); i >= 0; i--){
if(!createFolder(ls.get(i))){
iserror = true;
break;
}
}
if(!iserror) b = true;
}catch(Exception e){
LastError = "创建目录操作出错,错误信息="+e.getMessage();
}
return b;
}
public boolean delFile(String filePathAndName) {
boolean b = false;
try {
File DelFile = new File(filePathAndName);
if(DelFile.exists() && DelFile.isFile()){
b = DelFile.delete();
}
}
catch (Exception e) {
LastError = e.toString();
}
return b;
}
public boolean fileExists(String filePath){
File f = new File(filePath);
return f.exists();
}
public boolean delFolder(String folderPath) {
boolean b = false;
try {
if(delAllFile(folderPath)){ //删除完里面所有内容
java.io.File pf = new java.io.File(folderPath);
b = pf.delete(); //删除空文件夹
}
}
catch (Exception e) {
LastError = ("删除文件夹操作出错");
}
return b;
}
public String FindPath(File f,String name){
String pname = "";
if(f.getName().equals(name)){
pname = f.getPath();
}else{
if(f.isDirectory()){
File[] fs = f.listFiles();
for(File tmpf : fs){
String name1 = FindPath(tmpf,name);
if(name1.indexOf(name) > 0){
pname = tmpf.getPath();
break;
}
}
}else{
pname = "";
}
}
return pname;
}
public boolean delAllFile(String path) {
boolean b = false;
File file = new File(path);
if (!file.exists()) {
return b;
}
if (!file.isDirectory()) {
return b;
}
boolean iserror = false;
String[] tempList = file.list();
File temp = null;
for (int i = 0; i < tempList.length; i++) {
if (path.endsWith(File.separator)) {
temp = new File(path + tempList[i]);
}else{
temp = new File(path + File.separator + tempList[i]);
}
if (temp.isFile()) {
if(!temp.delete()){
iserror = true;
break;
}
}
if (temp.isDirectory()) {
if(!delFolder(path+File.separator+ tempList[i])){
iserror = true;
break;
}
}
}
if(!iserror) b = true;
return b;
}
public boolean copyFileForChannel(String srcPathFile, String destPathFile){
boolean b = true;
FileChannel srcChannel = null;
FileChannel destChannel = null;
try {
srcChannel = new FileInputStream(new File(srcPathFile)).getChannel();
destChannel = new FileOutputStream(new File(destPathFile)).getChannel();
srcChannel.transferTo(0, srcChannel.size(), destChannel);
}catch (Exception e) {
b = false;
}finally{
try {
if(srcChannel != null) srcChannel.close();
srcChannel= null;
} catch (IOException e) {
this.LastError = e.getMessage();
}
try {
if(destChannel != null) destChannel.close();
destChannel= null;
} catch (IOException e) {
this.LastError = e.getMessage();
}
}
return b;
}
public byte[] readFileToByte(String filename){
byte[] b = null;
InputStream inStream = null;
byte[] buffer = new byte[1024*10];
ByteArrayOutputStream out = new ByteArrayOutputStream();
int len = 0;
long size = 0;
try {
inStream = new FileInputStream(filename);
while((len = inStream.read(buffer)) != -1){
size += len;
out.write(buffer, 0, len);
}
if(size > 0){
b = out.toByteArray();
}
}catch (Exception e) {
b = null;
}finally{
try {
if(inStream != null) inStream.close();
inStream= null;
} catch (IOException e) {
}
}
return b;
}
public String readFileToText(String filename,String encoding){
StringBuffer str = new StringBuffer();
InputStream inStream = null;
BufferedReader br = null;
try {
inStream = new FileInputStream(filename);
br = new BufferedReader(new InputStreamReader(inStream,encoding));
String line;
while((line = br.readLine()) != null){
str.append(line);
}
}catch (Exception e) {
}finally{
if(br != null) {
try {
br.close();
} catch (IOException e) {
}
}
try {
if(inStream != null) inStream.close();
inStream= null;
} catch (IOException e) {
}
}
return str.toString();
}
public boolean copyFile(String srcPathFile, String destPathFile) {
boolean b = true;
InputStream inStream = null;
FileOutputStream fs = null;
try {
//int bytesum = 0;
int byteread = 0;
File srcfile = new File(srcPathFile);
if (srcfile.exists()) {
inStream = new FileInputStream(srcPathFile);
fs = new FileOutputStream(destPathFile);
byte[] buffer = new byte[64*1024];
while((byteread = inStream.read(buffer)) != -1){
//bytesum += byteread;
fs.write(buffer, 0, byteread);
}
}
}catch (Exception e) {
e.printStackTrace();
b = false;
}finally{
if(inStream != null)
try {
inStream.close();
} catch (IOException e) {
this.LastError = e.getMessage();
}
if(fs != null)
try {
fs.close();
} catch (IOException e) {
this.LastError = e.getMessage();
}
}
return b;
}
public boolean copyFolder(String srcPath, String destPath) {
boolean b = false;
boolean iserror = false;
try {
if(this.createFolder(destPath)){
File f = new File(srcPath);
没有合适的资源?快使用搜索试试~ 我知道了~
maven Springmvc 4.16 环境搭建
共64个文件
class:19个
java:19个
xml:5个
4星 · 超过85%的资源 需积分: 9 112 下载量 126 浏览量
2015-05-12
15:03:27
上传
评论
收藏 92KB ZIP 举报
温馨提示
该项目是本人写的文档 maven SpringMVC4 JPA 开发环境的搭建 配套工程
资源推荐
资源详情
资源评论
收起资源包目录
ghybhrm.zip (64个子文件)
ghybhrm
.project 1KB
src
test
java
main
webapp
WEB-INF
springMvc4-servlet.xml 8KB
jdbc.properties 1KB
log4j.properties 582B
web.xml 3KB
index.html 659B
js
jquery-1.9.1.min.js 90KB
pubjs.js 2KB
login.jsp 649B
resources
java
com
service
OrgService.java 92B
SelfDataService.java 106B
UserService.java 163B
implement
UserServiceImpl.java 2KB
OrgServiceImpl.java 496B
SelfDataServiceImpl.java 475B
model
User.java 1KB
Org.java 2KB
zksoo
utils
PubFunction.java 2KB
FileHelp.java 14KB
controller
ControllerCenter.java 2KB
dao
SelfDataDao.java 95B
UserDao.java 1KB
OrgDao.java 182B
implement
SelfDataImpl.java 941B
OrgDaoImpl.java 2KB
springmvc
filter
SessionFilter.java 2KB
task
IMyTestService.java 83B
MyTestServiceImpl.java 378B
log4j.properties 582B
target
m2e-wtp
web-resources
META-INF
MANIFEST.MF 114B
maven
ghy
ghybhrm
pom.properties 212B
pom.xml 8KB
classes
com
service
UserService.class 214B
OrgService.class 161B
SelfDataService.class 185B
implement
SelfDataServiceImpl.class 793B
OrgServiceImpl.class 739B
UserServiceImpl.class 3KB
model
User.class 2KB
Org.class 3KB
zksoo
utils
FileHelp.class 12KB
PubFunction.class 3KB
controller
ControllerCenter.class 3KB
dao
OrgDao.class 286B
SelfDataDao.class 173B
implement
OrgDaoImpl.class 3KB
SelfDataImpl.class 2KB
UserDao.class 445B
springmvc
filter
SessionFilter.class 3KB
task
MyTestServiceImpl.class 737B
IMyTestService.class 141B
log4j.properties 582B
test-classes
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 252B
org.eclipse.m2e.core.prefs 90B
org.eclipse.jdt.core.prefs 430B
org.eclipse.wst.common.project.facet.core.xml.bak 252B
org.eclipse.wst.validation.prefs 50B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.core.resources.prefs 75B
org.eclipse.wst.common.component 664B
.jsdtscope 575B
pom.xml 8KB
.classpath 1KB
共 64 条
- 1
资源评论
- wuji19892016-08-02还可以 maven入门很不错
- loser__2015-08-19感觉挺好用的
smander
- 粉丝: 1
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- DSP开发实战教程-国产DSP替代进口TI DSP的使用技巧 进芯DSP替换文件
- 植被恢复能力估算python代码(KNDVI代码).zip
- 基于java打造的深度学习框架,帮助你快速搭建神经网络,实现模型推理与训练,引擎支持自动求导,多线程与GPU运算
- 界线与不动产测绘智能计算经纬度及标注软件
- CANOPEN使用方法与教程
- 极影毁片圆 · 电脑字体设置.zip
- 同态加密部分算法实现Homomorphic-Encryption-main.zip
- helib同态加密socket通信helibsocket-master.zip
- pll_inst.vhd
- 快速入门同态加密homomorphic-encryption-master.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功