1R_F<+C&7^N^_J;>a}}s+0K1CnP1Q%
zXc1H{3JQ#%RX?R=KOj0Ph?^K@&Uw!{?>qzZ9q4M|uiw`$fDAUhP#BW!n`C?ImbK)E
z5|JZ__25?Atv~+5Fr-YY
z!tI7-)GKAHP!mnlI^+Lcq#=&EAl!&CsFpZqNXVF)@br}}-<7n_vSjC$BRMRr%x@IAH@5;0epwa^L
z4#xH9Gp61UKhmQwn0=(G0*y|MA`pQOIs%kU4;%<0M2ftaM*^&$Eg(tL42xKz7^d17
zsR(WT1k6SXUaIXPI)c-NIBkg2Fu*DFe?9klALt?22Ji>m
CUt1ag
diff --git a/src/com/platform/controller/DefaultController.java b/src/com/platform/controller/DefaultController.java
index 4722c5d6..ab8070bd 100644
--- a/src/com/platform/controller/DefaultController.java
+++ b/src/com/platform/controller/DefaultController.java
@@ -4,6 +4,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@@ -11,18 +12,30 @@ import com.platform.utils.Configs;
@Controller
public class DefaultController {
- @RequestMapping("/")
- public ModelAndView defaultHandler(HttpServletRequest req, HttpServletResponse res){
+
+
+ @RequestMapping("/tes")
+ public Object defaultHandler(HttpServletRequest req, HttpServletResponse request) {
//处理不匹配的请求
- System.out.println("index");
- return new ModelAndView("index");
-
+ try {
+
+ System.out.println("fsdfds");
+
+ return "listAll";
+ } catch (Exception e) {
+ e.printStackTrace();
+
+ return "result";
+ }
+
+
}
@RequestMapping("/test")
- public void test(HttpServletRequest req, HttpServletResponse res){
+ public ModelMap test(HttpServletRequest req, HttpServletResponse res){
//System.out.println(Class.class.getClass().getResource("/").getPath());
System.out.println(Configs.EXTRACT_LOG_LOCALTION);
+ return new ModelMap();
}
}
From d7da61c394589157bc4ede3c4730d2ebb9d8ab2b Mon Sep 17 00:00:00 2001
From: chenlw <874313221@qq.com>
Date: Thu, 8 Sep 2016 11:26:14 +0800
Subject: [PATCH 03/15] =?UTF-8?q?=E6=94=B9=E7=BC=96=E7=A0=81=E6=96=B9?=
=?UTF-8?q?=E5=BC=8Futf8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.classpath | 6 +-
WebContent/WEB-INF/config/config.properties | 2 +-
build/classes/.gitignore | 4 +-
.../controller/DataModelController.class | Bin 5314 -> 5307 bytes
.../controller/DefaultController.class | Bin 1651 -> 1342 bytes
.../platform/entities/EncodedInfoEntity.class | Bin 1136 -> 1136 bytes
.../classes/com/platform/utils/Configs.class | Bin 1676 -> 1784 bytes
src/com/base/BaseController.java | 53 +--
src/com/base/Constant.java | 28 +-
src/com/base/Custom4exception.java | 45 +-
src/com/base/CustomException.java | 53 +--
src/com/base/FileOperate.java | 383 ------------------
src/com/base/Resource.java | 20 +-
src/com/base/WritefileThread.java | 68 ----
.../controller/DataModelController.java | 9 +-
.../controller/DefaultController.java | 15 +-
.../platform/controller/FolderController.java | 35 ++
src/com/platform/dao/EncodeInfoDao.java | 42 +-
src/com/platform/entities/DataInfoEntity.java | 30 +-
.../platform/entities/EncodedInfoEntity.java | 10 +-
src/com/platform/entities/PagerOptions.java | 24 +-
src/com/platform/oracle/OracleConnector.java | 6 +-
.../platform/service/DataInfoServiceImp.java | 8 +-
.../platform/service/EncodeInfoService.java | 2 +-
.../service/EncodeInfoServiceImpl.java | 6 +-
.../platform/service/OracleExtractHelper.java | 22 +-
.../platform/service/OracleStatusService.java | 22 +-
src/com/platform/utils/ConfigLoder.java | 2 +-
.../platform/utils/ConfigPropertyReader.java | 2 +-
src/com/platform/utils/Configs.java | 35 +-
src/com/platform/utils/ConfigsLoader.java | 4 +-
src/com/platform/utils/FileOperateHelper.java | 8 +-
src/com/platform/utils/UtilsHelper.java | 8 +-
test/com/platform/test/TestController.java | 4 +-
test/com/platform/test/TestEncodeInfoDao.java | 8 +-
test/com/platform/test/TestEncodeService.java | 4 +-
test/com/test/base/ResourceTest.java | 23 --
37 files changed, 260 insertions(+), 731 deletions(-)
delete mode 100644 src/com/base/FileOperate.java
delete mode 100644 src/com/base/WritefileThread.java
create mode 100644 src/com/platform/controller/FolderController.java
delete mode 100644 test/com/test/base/ResourceTest.java
diff --git a/.classpath b/.classpath
index 7155d58e..b39d1be2 100644
--- a/.classpath
+++ b/.classpath
@@ -4,15 +4,11 @@
-
-
-
-
-
+
diff --git a/WebContent/WEB-INF/config/config.properties b/WebContent/WEB-INF/config/config.properties
index 56b7bdea..6f9d7280 100644
--- a/WebContent/WEB-INF/config/config.properties
+++ b/WebContent/WEB-INF/config/config.properties
@@ -4,7 +4,7 @@
# 椹卞姩绋嬪簭
jdbc.mysql.driver=com.mysql.jdbc.Driver
# 杩炴帴url
-jdbc.mysql.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
+jdbc.mysql.url=jdbc:mysql://192.168.0.101:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
# 鐢ㄦ埛鍚
jdbc.mysql.username=root
# 瀵嗙爜
diff --git a/build/classes/.gitignore b/build/classes/.gitignore
index 67f303f0..4bc3afa4 100644
--- a/build/classes/.gitignore
+++ b/build/classes/.gitignore
@@ -1,2 +1,2 @@
-/com/
-/dataSystem.properties
+/com
+/spring-applicationContext-test.xml
diff --git a/build/classes/com/platform/controller/DataModelController.class b/build/classes/com/platform/controller/DataModelController.class
index 6d59835f007275654e707e8692e2fa22d4157103..837dcfdebf39365d3eb889b3609a1f628200473b 100644
GIT binary patch
delta 227
zcmX@4xm$CBgP=fGVp*boPGVlVzJF3yYI4cOh-zL&iOE-ZZCPa*SQ+Fti}9&5x~ed+
zGpI7~GpI30FsK7b4F)>~O$J{EErw7AZH7b!9fk@9U507~J%&j@xj77m467N87&Zgx
zZ44$1dl`%w4l$T*ZsLz%z(ZLlpolY2#DzhU!4+tP8<2Eo
z2n3SR44#{x3Ys%2`T>>r1C<0YC<7%l7=nP>gBe1AFbT-cVF;gWD}0+VcCw^M25TY%
L2Sd{2HW3>D7E&z%
delta 234
zcmdn3c}R1DgM@f;ey)B}VsWaz6OeGu&nqd)&&f$G+89{P%P2YdEUzuA90MzZ{APYW
zbw*cJ26hHD27U&01_=fYAWM_MjzNpTmqD8$ltG6fkwKTCfRdqgAv1O
z24jZJKzbX4DZ^d{6NW0@DB{W>$>0Vw
z#vRD=U>byWKd=Z0=gg=XhaAQhB71p**Odmlg)&0GsaC8
R63JjqV&Gs%o?I_t0|2SCFWUeB
diff --git a/build/classes/com/platform/controller/DefaultController.class b/build/classes/com/platform/controller/DefaultController.class
index f975e29e332db9ea13d5969d0f8c27a806e0490f..9194050341ac120c7dd7616d178826116f726d0f 100644
GIT binary patch
delta 213
zcmey&vyY4G)W2Q(7#J9g8O$bfnFtDGC6*=X=OpH(>-#5Vr6!kb4ExQ*$EshFT3o`(
zpvPdq&Y(Ye8M8dIA%oH66U@4kTUojoc_$07#E@IWKWnvHjn#jk%$RG&B
zLeUJ2#SA(O>_9Oe1||k(AkDRjL1Yty?luOQjX)j~0~bgPNHZ`nJ}3J{eH
lJPf=*9!Oq|K^Xxl*a(27xl)UYnJDryClig3`7h!~Z4*sd?6Sa!+omKZPG
zy_xmG(UWI5NFovM{yQEu#u1Xr;mw=*zHer}%%T0WQ2g=d>mkr!(ITU$efU(XT9}Hn
zez@Vby;!?*5?W!9L}9n9qur%nnH78ft*I7@e6G-1obM*vzJf>NDmgm00(7|g(t`jFwPb*aErDAY7
z@%%TBz0IdyyQ|aB#(Pyv>*lNM5P62vkEXM2Fd@e?QR1d3*=fm2^2)2I7#B;h9WiOj
z?;J3>PkoP}JsMxAn6uR#$_F?v%D0s9jpjZx--RvT6LMD?3~Y(#kA_spQRR$OB}N$L
z0;61HWr9nb649084HOuZN_H{EW%2PZ8>dD_+A7S^lA#X-&7poXssx{xD#ODg_kywj
Fe*u!IZ*l+t
diff --git a/build/classes/com/platform/entities/EncodedInfoEntity.class b/build/classes/com/platform/entities/EncodedInfoEntity.class
index f920dc4d2cf3c57a9ef5aa9667a70937a4afebc9..ca2439bd9284f229bab46b209fc0d15f153bedfe 100644
GIT binary patch
delta 101
zcmeys@quGQ6B8rfm)@(M7pFbFbmG6*s7F$hn-#uUIP29~p7)?k%lU}cb=
voXPCQCm)@(MAqFbFenGKetnF^EpS#uUIP0hY62)?k%kU}cb<
voXPCQr~nkRWmN(4RVRO9PL$OIs%Bu|VPFK33Jm-V0zjIPK^sUiG3WpQPFWD}
diff --git a/build/classes/com/platform/utils/Configs.class b/build/classes/com/platform/utils/Configs.class
index 6bc46bf3d7a7fdae436c70e57756ebdeaada2dcb..ef6f24b0c30d29e1e22a23a0e34bcb7c6cf0f308 100644
GIT binary patch
delta 925
zcmYjP%Tg0T6g{1gkiE*@qEk|84+jn!U()^jOoGkcmAfD|~(8y09vnCZFXd_H9+;;C%XOb5_-
z^yQ~$zAaE+uy?DrRSaPOcj__dta`e}?hb64zNM3V`En
ziSF7tC5aogulEu?&P3g)|AWLXdY%2cg?uZu?Sr3o)YFJP2v8h47hj;b;aq%?VzQoc
zJJ@24iX(aO;!)F`>`7)ZJ-ZfII8mUE%)S$*5joige^iof^i2X&yMOl
zLBETLifJ^|h{pR$oZx|rN9wVQsj%<2i)l6EVop7A@l>VU1EkfGi)ALW>bZ*?k$9zE
zyI5CmTx_Z>7jJpl;pN>C9p-^WYnpx*ppn{9WI~uO-a@l)Bd6P`y-p0$z@jve5%PK*
zJ(whR27O4PpY{$SL%&!Kxd_$}!zK)rb!pIz$p6#(MF{zZzJX)dXJ_+Bh}2u;>Gwxe
Lh!d#lGJF33KO}566g^D_GIWGAV!(+(z!1=vfkeasR74R36;x0GLySrAg=ZyhSY>VLCiT7~
z)e9*X?6gYV_$%&QS>D^>E&6nybNhCm)9-KOb0qZh-`67m892?*bW=y0>xtHnUm`s$
z&{=Ty>yBLvVFY8H7!`;)wUU*8pD&b)mhF_L_N-;6R4UdaE+X!J@0bfFBti%WFzI%A
zV&j)3B(IVJ!CJmzA1qYtVh{ppi3q~nc#8LC-BnK}ctzp_S6_8Md4?L-B)Z_|;u{j(
zhz2k#;IALlKNPFX-jY!82XKd2r;D~5Jp;)h{3ELj~n&%ZieY4`Z+R#l#oFRg)qo*7^E-^
zl6`|@*dUoSNX873EraC7b$ppd2Ld>c0lL*7@xKZAE32VHT+kR-69z9S%V0{0Lu52^
zYFc9^>ieT{UES1}Q@1td)q=)-^+02pxfS(D;|X)?>Y2uddZF=3ZEL*dVV8$Dtp**|
zfwwfS&>Mj+6Ch&|`d_+f>?3=FWNeh)YJy%QNlccqoT1ca>Du$8E@GJWj$jRA*gzax
tNMIL}D4EV6Lloz+J&TYH`VwDIX>mc^ob7M3W{*6czk^K$0#(yz|38bYZqon&
diff --git a/src/com/base/BaseController.java b/src/com/base/BaseController.java
index 8a6c02c2..2192dbc5 100644
--- a/src/com/base/BaseController.java
+++ b/src/com/base/BaseController.java
@@ -1,47 +1,54 @@
/**
- * 文件名 : BaseController.java
- * 版权 : XX科技有限公司。
- * 描述 : <描述>
- * 修改时间:2016年9月7日
- * 修改内容:<修改内容>
+ * 鏂囦欢鍚 锛 BaseController.java
+ * 鐗堟潈 : XX绉戞妧鏈夐檺鍏徃銆
+ * 鎻忚堪 : <鎻忚堪>
+ * 淇敼鏃堕棿锛2016骞9鏈7鏃
+ * 淇敼鍐呭锛<淇敼鍐呭>
*/
package com.base;
import javax.servlet.http.HttpServletRequest;
+import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.ExceptionHandler;
+import com.platform.utils.Configs;
+
/**
- * <一句话功能简述>
- * <功能详细描述>
+ * <涓鍙ヨ瘽鍔熻兘绠杩>
+ * <鍔熻兘璇︾粏鎻忚堪>
* @author chen
- * @version [版本号,2016年9月7日]
- * @see [相关类/方法]
- * @since [产品/模块版本]
+ * @version [鐗堟湰鍙凤紝2016骞9鏈7鏃
+ * @see [鐩稿叧绫/鏂规硶]
+ * @since [浜у搧/妯″潡鐗堟湰]
*/
-public class BaseController {
+public class BaseController {
+
+ /** log4j */
+ public static Logger log = Logger.getRootLogger();
/**
- * <一句话功能简述> 基于@ExceptionHandler异常处理----全局异常处理
- * <功能详细描述>
+ * <涓鍙ヨ瘽鍔熻兘绠杩> 鍩轰簬@ExceptionHandler寮傚父澶勭悊----鍏ㄥ眬寮傚父澶勭悊
+ * <鍔熻兘璇︾粏鎻忚堪>
* @param request
- * @param ex 异常
+ * @param ex 寮傚父
* @return
- * @see [类、类#方法、类#成员]
+ * @see [绫汇佺被#鏂规硶銆佺被#鎴愬憳]
*/
@ExceptionHandler
- public String exp(HttpServletRequest request, Exception ex) {
+ public Object exp(HttpServletRequest request, Exception ex) {
request.setAttribute("ex", ex);
System.err.println("BaseController --exp ");
- // 根据不同错误转向不同页面
- if(ex instanceof CustomException) {
- //TODO 从新封装json
- System.err.println("BaseController --exp -- CustomException ");
- return "error-business";
+ // 鏍规嵁涓嶅悓閿欒杞悜涓嶅悓椤甸潰
+ if(ex instanceof CustomException) {
+ CustomException cuse = (CustomException) ex;
+ log.error(Configs.GLOBAL_EXP_CUSTOM);
+ //TODO 浠庢柊灏佽json
+ return "{"+Configs.GLOBAL_EXP_CUSTOM+":"+cuse.getMsg()+"}";
} else {
- //TODO 其他错误则 调到指定页面
-
+ //TODO 鍏朵粬閿欒鍒 璋冨埌鎸囧畾椤甸潰
+ log.error(Configs.GLOBAL_EXP_NOT_CUSTOM, ex);
return "error";
}
}
diff --git a/src/com/base/Constant.java b/src/com/base/Constant.java
index 87bd657d..4d336465 100644
--- a/src/com/base/Constant.java
+++ b/src/com/base/Constant.java
@@ -1,32 +1,22 @@
package com.base;
-import java.io.File;
-
/**
- * @描述 常量类
- * @author chen
- * @date 2016年8月30日
- * @package com.base
+ * <涓鍙ヨ瘽鍔熻兘绠杩>
+ * <鍔熻兘璇︾粏鎻忚堪>
+ * @author chen
+ * @version [鐗堟湰鍙凤紝2016骞9鏈8鏃
+ * @see [鐩稿叧绫/鏂规硶]
+ * @since [浜у搧/妯″潡鐗堟湰]
*/
public class Constant {
- /** 配置文件文件-dataSystem.properties */
- public static String SYSTEM_PROPERTIES_FIEL_PATH = "/com/base/dataSystem.properties";
-
- /** 国际话配置文件文件-i18n.properties */
+ /** 鍥介檯璇濋厤缃枃浠舵枃浠-i18n.properties */
public static String I18N_PROPERTIES_FIEL_PATH = "/com/base/i18n.properties";
- /** 记录异常的文件-system_exception.txt-的位置-- */
- public final static String SYSTEM_EXCEPTION_FILEPATH = "\\log\\system_exception.txt";
-
-
- /** WritefileThread-线程睡眠时间--3000 */
+ /** WritefileThread-绾跨▼鐫$湢鏃堕棿--3000 */
public final static long THREAD_SLEEP_WRITEFILETHREAD = 3000;
- /** 是否将异常写入文件 */
- public final static String IS_WRITE_LOGFILE = "iswritelogfile";
-
- /** CustomException记录报异常的对象的对象个数--10 */
+ /** CustomException璁板綍鎶ュ紓甯哥殑瀵硅薄鐨勫璞′釜鏁--10 */
public final static int CustomException_log_object_size = 10;
diff --git a/src/com/base/Custom4exception.java b/src/com/base/Custom4exception.java
index cfbab1e6..2aeba6c6 100644
--- a/src/com/base/Custom4exception.java
+++ b/src/com/base/Custom4exception.java
@@ -1,41 +1,20 @@
package com.base;
-
/**
- * @描述 异常常量编码
- * @author chen
- * @date 2016年8月22日
- * @package com.base
+ * <涓鍙ヨ瘽鍔熻兘绠杩> 寮傚父甯搁噺缂栫爜
+ * <鍔熻兘璇︾粏鎻忚堪>
+ * @author chen
+ * @version [鐗堟湰鍙凤紝2016骞9鏈8鏃
+ * @see [鐩稿叧绫/鏂规硶]
+ * @since [浜у搧/妯″潡鐗堟湰]
*/
public class Custom4exception {
- //3003001001 : 第一位:标识异常, 第二到第四位:标识模块,第五道第七位:标识类别,第八道第十位标识具体异常
- /** 3:异常
- * 003:虚拟机模块
- * 001:软件依赖虚拟机资源类别
- * 001:启动异常
+ //3003001001 : 绗竴浣嶏細鏍囪瘑寮傚父锛 绗簩鍒扮鍥涗綅锛氭爣璇嗘ā鍧楋紝绗簲閬撶涓冧綅锛氭爣璇嗙被鍒紝绗叓閬撶鍗佷綅鏍囪瘑鍏蜂綋寮傚父
+ /**eg
+ * 3锛氬紓甯
+ * 003锛氳櫄鎷熸満妯″潡
+ * 001锛氳蒋浠朵緷璧栬櫄鎷熸満璧勬簮绫诲埆
+ * 001锛氬惎鍔ㄥ紓甯
*/
- /** 虚拟机-资源-虚拟机VM启动异常 */
- public final static String vbox_start_exp = "3003001001";
-
- /** 虚拟机-资源-虚拟机VBoxManage.exe 不存在异常 */
- public final static String vbox_exe_non_exist_exp = "3003001002";
-
- /** 虚拟机-共享-设置共享文件夹中断异常 */
- public final static String share_dir_interrupted_exp = "3003002001";
-
- /** 数据管理-数据上报-中断或读写异常 */
- public final static String data_manage_interrupted_exp = "3004001001";
-
- /** 公共模块utils-xml类-xml非法异常 */
- public final static String xml_field_Illega_exp = "3005001001";
-
- /** 公共模块utils-xml类-document异常 */
- public final static String xml_docu_exp = "3005001002";
-
- /** 公共模块utils-xml类-读写异常 */
- public final static String xml_io_exp = "3005001003";
-
- /** 公共模块utils-oracle类-读写异常 */
- public final static String oracle_io_exp = "3005002001";
}
diff --git a/src/com/base/CustomException.java b/src/com/base/CustomException.java
index f9c4192c..1c1d43e9 100644
--- a/src/com/base/CustomException.java
+++ b/src/com/base/CustomException.java
@@ -1,35 +1,38 @@
package com.base;
+import org.apache.log4j.Logger;
+/**
+ * <涓鍙ヨ瘽鍔熻兘绠杩>
+ * <鍔熻兘璇︾粏鎻忚堪>
+ * @author chen
+ * @version [鐗堟湰鍙凤紝2016骞9鏈8鏃
+ * @see [鐩稿叧绫/鏂规硶]
+ * @since [浜у搧/妯″潡鐗堟湰]
+ */
@SuppressWarnings("serial")
public class CustomException extends Exception {
-
- /** 自定义异常信息-错误信息 */
+
+ /** log4j */
+ public static Logger log = Logger.getRootLogger();
+
+ /** 鑷畾涔夊紓甯镐俊鎭-閿欒淇℃伅 */
private String msg;
- /** 操作对象 */
+ /** 鎿嶄綔瀵硅薄 */
private Object[] objArray;
- /** 异常 */
+ /** 寮傚父 */
private Throwable cause;
- static{
- // 是否 启动 记录 异常的线程
- if (Boolean.valueOf(Resource.getProperties().get(Constant.IS_WRITE_LOGFILE))) {
- //启动 记录 异常的线程
- WritefileThread wt = new WritefileThread();
- wt.start();
- }
- }
-
public CustomException() {
super();
}
/**
- * @功能 将异常记录进文件
- * @param code 异常编码
- * @param msg 自定义异常信息
+ * @鍔熻兘 灏嗗紓甯歌褰曡繘鏂囦欢
+ * @param code 寮傚父缂栫爜
+ * @param msg 鑷畾涔夊紓甯镐俊鎭
* @param e
* @param obj
*/
@@ -41,12 +44,12 @@ public class CustomException extends Exception {
sbuf.append(code);
sbuf.append("\r\n");
msg = Resource.getProperties().get(code);
- // 记录自定义的 异常
+ // 璁板綍鑷畾涔夌殑 寮傚父
if (null != msg) {
sbuf.append(msg);
sbuf.append("\r\n");
}
- // 记录原始的异常
+ // 璁板綍鍘熷鐨勫紓甯
if (null != e) {
StackTraceElement[] array = e.getStackTrace();
cause = e.getCause();
@@ -55,7 +58,7 @@ public class CustomException extends Exception {
sbuf.append("\r\n");
}
}
- //记录 出现异常时 当前的对象
+ //璁板綍 鍑虹幇寮傚父鏃 褰撳墠鐨勫璞
if (null != obj) {
Object[] array = obj;
sbuf.append("Object[] size : ");
@@ -80,14 +83,12 @@ public class CustomException extends Exception {
}
sbuf.append("\r\n");
- // 是否 写入 文件
- if (Boolean.valueOf(Resource.getProperties().get(Constant.IS_WRITE_LOGFILE))) {
- WritefileThread.getStrArray().add(sbuf.toString());
- }
+ // 鏄惁 鍐欏叆 鏂囦欢
+ log.error(sbuf.toString());
}
/**
- * @功能 获得msg
+ * @鍔熻兘 鑾峰緱msg
* @return msg
*/
public String getMsg() {
@@ -95,7 +96,7 @@ public class CustomException extends Exception {
}
/**
- * @功能 获得objArray
+ * @鍔熻兘 鑾峰緱objArray
* @return objArray
*/
public Object[] getObjArray() {
@@ -103,7 +104,7 @@ public class CustomException extends Exception {
}
/**
- * @功能 获得cause
+ * @鍔熻兘 鑾峰緱cause
* @return cause
*/
public Throwable getCause() {
diff --git a/src/com/base/FileOperate.java b/src/com/base/FileOperate.java
deleted file mode 100644
index 718d3d4d..00000000
--- a/src/com/base/FileOperate.java
+++ /dev/null
@@ -1,383 +0,0 @@
-package com.base;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.RandomAccessFile;
-import java.nio.channels.FileLock;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-import javax.swing.filechooser.FileSystemView;
-
-/**
- * @描述 文件操作
- * @author chen
- * @date 2016年8月8日
- * @package com.utils
- */
-public class FileOperate {
- private final static String localDiskName = "本地磁盘";
- private final static String enlocalDiskName = "Local Disk";
- private final static String CD = "CD";
- private final static String DVD = "DVD";
- public static String usbPath = "";
-
- /**
- * @功能 获取全部的外部移动硬盘路径
- *
- * @return
- */
- public static List filterDiskPath() {
- FileSystemView fileSystemView = FileSystemView.getFileSystemView();
- List diskPathName = new ArrayList();
- File[] roots = File.listRoots();
- for (File file : roots) {
- String diskName = fileSystemView.getSystemTypeDescription(file);// 获取磁盘的类型描述信息
- if (diskName.startsWith(localDiskName) || diskName.startsWith(enlocalDiskName) || diskName.contains(CD)
- || diskName.contains(CD) || diskName.contains(DVD)) // 当磁盘为可移动磁盘时{
- continue;
- diskPathName.add(file.getAbsolutePath());
- }
- return diskPathName;
- }
-
- /**
- * @功能 创建文件夹
- * @param path
- * 上级目录
- * @param dirName
- * 待创建的目录
- * @return
- */
- public static int createDir(String path, String dirName) {
- File dirFile = new File(path + "\\" + dirName);
- if (!dirFile.exists()) {
- if (!dirFile.mkdirs()) {
- System.out.println("目录不存在,创建失败!");
- return 2;
- }
- return 1;
- }
- return 0;
- }
-
- /**
- * @功能 检测数据文件是否完整
- *
- * @param path
- * 文件绝对路径
- * @return
- */
- public static boolean isFileExists(String path) {
- File file = new File(path);
- if (file.exists())
- return true;
- return false;
- }
-
- /**
- * @功能 文件是否存在
- *
- * @param name
- * 文件绝对路径
- * @return
- */
- public static boolean file_dir_exist(String name) {
-
- try {
- File file = new File(name);
- if (!file.exists()) {
- return false;
- // return true;
- }
- }
- catch (Exception e) {
- // TODO: handle exception
- return false;
- }
- return true;
- }
-
- /**
- * @功能 随机生成26以内的数字拼接的字符串(?什么用?)
- * @param length
- * 拼接次数
- * @return
- */
- public static String getRandomString(int length) { // length表示生成字符串的长度
- String base = "abcdefghijklmnopqrstuvwxyz";
- Random random = new Random();
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < length; i++) {
- int number = random.nextInt(base.length());
- sb.append(base.charAt(number));
- }
- return sb.toString();
- }
-
- /**
- * @功能 以字符串方式读取文件内容
- * @param fiel_name
- * 文件名
- * @return 字符串
- */
- public static String read_fileToStr(String fiel_name) {
- String str = "";
- try {
- File file = new File(fiel_name);
- String lineTxt = "";
- InputStreamReader read = new InputStreamReader(new FileInputStream(file), "gbk");// 考虑到编码格式
- BufferedReader bufferedReader = new BufferedReader(read);
- while ((lineTxt = bufferedReader.readLine()) != null) {
- str = str + lineTxt;
- }
- bufferedReader.close();
- read.close();
- }
- catch (Exception e) {
- e.printStackTrace();
- return "Exception";
- }
- return str;
- }
-
- /**
- * @功能 读取文件路径的各级目录,以数组形式返回
- * @param path_filename
- * 文件或文件夹路径
- * @return 数组
- */
- public static String get_filename_from_path(String path_filename) {
- String[] strings = path_filename.split("\\\\");
-
- return strings[strings.length - 1];
- }
-
- /**
- * @功能 查找dirPath目录下的所有文件
- * @param dirPath
- * 目录
- * @return 所有文件数组
- */
- public static List findAllFilenameFromPath(String dirPath) {
- ArrayList fileAbsolutePaths = new ArrayList<>();
- FileOperate.findFiles(dirPath, fileAbsolutePaths);
- return fileAbsolutePaths;
- }
-
- /**
- * @功能 删除目录下所有文件包含文件夹
- * @param dirPath
- * 目录
- * @return
- */
- public static boolean delAllFileByDir(String dirPath) {
- boolean flag = false;
- File file = new File(dirPath);
- // 判断目录或文件是否存在
- if (!file.exists()) { // 不存在返回 false
- return flag;
- }
- else {
- // 判断是否为文件
- if (file.isFile()) { // 为文件时调用删除文件方法
- return deleteFile(dirPath);
- }
- else { // 为目录时调用删除目录方法
- return deleteDirectory(dirPath);
- }
- }
- }
-
- /**
- * @功能 写文件
- * @param content
- * 文件内容
- * @param filePathName
- * 文件绝对路径
- */
- public static void writeFile(List