diff --git a/MDAT-DEV/src/main/Plugins/Oracle/FileUtil.java b/MDAT-DEV/src/main/Plugins/Oracle/FileUtil.java index 9f79145..4d05959 100644 --- a/MDAT-DEV/src/main/Plugins/Oracle/FileUtil.java +++ b/MDAT-DEV/src/main/Plugins/Oracle/FileUtil.java @@ -47,12 +47,12 @@ public static String listfile(String dirPath, String encoding){ encoding = "utf-8"; } String r = ""; + File oF = new File(dirPath), l[] = oF.listFiles(); + String s = "", sT, sQ, sF = ""; + java.util.Date dt; + String fileCode=(String)System.getProperties().get("file.encoding"); + SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { - File oF = new File(dirPath), l[] = oF.listFiles(); - String s = "", sT, sQ, sF = ""; - java.util.Date dt; - String fileCode=(String)System.getProperties().get("file.encoding"); - SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); for (int i = 0; i < l.length; i++) { dt = new java.util.Date(l[i].lastModified()); sT = fm.format(dt); @@ -71,7 +71,7 @@ public static String listfile(String dirPath, String encoding){ s += sF; r = new String(s.getBytes(fileCode), encoding); }catch (Exception e){ - return e.getMessage(); + r = "ERROR://" + e.toString(); } return r; } @@ -81,7 +81,7 @@ public static String getPath() { try { result = directory.getAbsolutePath(); } catch (Exception e) { - return e.getMessage(); + result = "ERROR://" + e.toString(); } return result; } @@ -96,7 +96,7 @@ public static String readFile(String filePath){ sb.append(hex); } } catch (Exception e) { - sb.append(e.toString()); + sb.append("ERROR://" + e.toString()); } //System.out.println(sb.toString()); return sb.toString(); @@ -115,7 +115,7 @@ public static String writeFile(String filePath, String fileContext){ } os.close(); } catch (Exception e) { - return e.getMessage() + r = "ERROR://" + e.toString(); } return r; } @@ -134,4 +134,5 @@ public static String deleteFile(String path) { } return sb.toString(); } + } \ No newline at end of file diff --git a/MDAT-DEV/src/main/java/Controller/OracleController.java b/MDAT-DEV/src/main/java/Controller/OracleController.java index a2b078c..9ec1d20 100644 --- a/MDAT-DEV/src/main/java/Controller/OracleController.java +++ b/MDAT-DEV/src/main/java/Controller/OracleController.java @@ -415,6 +415,7 @@ public void showFilesOnTable(String path,String code){ if("null".equals(arrayFiles.get(0))){ oracleLogTextArea.appendText(Utils.log("路径读取失败!可能当前路径没有文件!")); + return; }else { for (int i = 0; i < arrayFiles.size(); i++) { String file = arrayFiles.get(i); diff --git a/MDAT-DEV/src/main/java/Dao/OracleDao.java b/MDAT-DEV/src/main/java/Dao/OracleDao.java index ebe7260..6eeb0ff 100644 --- a/MDAT-DEV/src/main/java/Dao/OracleDao.java +++ b/MDAT-DEV/src/main/java/Dao/OracleDao.java @@ -493,6 +493,10 @@ public ArrayList getFiles(String path,String code){ String sql = String.format(OracleSqlUtil.getFilesSql,path,code); try { tempres = executeSql(sql); + if(tempres.contains("ERROR://")){ + oracleController.oracleLogTextArea.appendText(Utils.log("获取所有文件失败!错误:"+ tempres.replace("ERROR://",""))); + return res; + } res = splitFiles(tempres); } catch (Exception e) { Platform.runLater(() ->{