|
@@ -86,35 +86,28 @@ public class DefaultConfig implements Configuration {
|
|
}
|
|
}
|
|
|
|
|
|
public List<String> readFileContents(String path) {
|
|
public List<String> readFileContents(String path) {
|
|
- if (!StringUtils.isEmpty(path_prefix)) path = path_prefix + path;
|
|
|
|
|
|
+ if (!StringUtils.isEmpty(path_prefix)) {
|
|
|
|
+ path = path_prefix + path;
|
|
|
|
+ }
|
|
|
|
+ return readDirectFileContents(path);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<String> readDirectFileContents(String path) {
|
|
InputStream is = null;
|
|
InputStream is = null;
|
|
List<String> fileContents = new ArrayList<String>(10);
|
|
List<String> fileContents = new ArrayList<String>(10);
|
|
try {
|
|
try {
|
|
- if (StringUtils.isEmpty(path)) path = DEFAULT_PATH;
|
|
|
|
- is = this.getClass().getClassLoader().getResourceAsStream(path);
|
|
|
|
|
|
+ if (StringUtils.isEmpty(path)) {
|
|
|
|
+ path = DEFAULT_PATH;
|
|
|
|
+ }
|
|
|
|
+ // is = this.getClass().getClassLoader().getResourceAsStream(path);
|
|
File file = new File(path);
|
|
File file = new File(path);
|
|
-// File file = new File(this.getClass().getResource(path).getFile());
|
|
|
|
|
|
+ // File file = new File(this.getClass().getResource(path).getFile());
|
|
is = new FileInputStream(file);
|
|
is = new FileInputStream(file);
|
|
if (is == null) {
|
|
if (is == null) {
|
|
throw new RuntimeException(path + ".......文件未找到!!");
|
|
throw new RuntimeException(path + ".......文件未找到!!");
|
|
}
|
|
}
|
|
|
|
|
|
- BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"), 512);
|
|
|
|
-
|
|
|
|
- EncrypDES encrypDES = new EncrypDES();
|
|
|
|
- String theWord = null;
|
|
|
|
- int i = 0;
|
|
|
|
- do {
|
|
|
|
- theWord = br.readLine();
|
|
|
|
- if (theWord != null && !"".equals(theWord.trim())) {
|
|
|
|
- if (i == 5) {
|
|
|
|
- logger.info("读取文件第六行解密前:" + theWord.trim());
|
|
|
|
- logger.info("读取文件第六行解密后:" + encrypDES.decryptor(theWord.trim()));
|
|
|
|
- }
|
|
|
|
- fileContents.add(encrypDES.decryptor(theWord.trim()));
|
|
|
|
- }
|
|
|
|
- i++;
|
|
|
|
- } while (theWord != null);
|
|
|
|
|
|
+ addFileContents(is, fileContents);
|
|
} catch (Exception ioe) {
|
|
} catch (Exception ioe) {
|
|
System.err.println("读取文件" + path + "出错.......................");
|
|
System.err.println("读取文件" + path + "出错.......................");
|
|
ioe.printStackTrace();
|
|
ioe.printStackTrace();
|
|
@@ -124,12 +117,59 @@ public class DefaultConfig implements Configuration {
|
|
return fileContents;
|
|
return fileContents;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public List<String> readTargetFileContents(String path) {
|
|
|
|
+ InputStream is = null;
|
|
|
|
+ List<String> fileContents = new ArrayList<String>(10);
|
|
|
|
+ try {
|
|
|
|
+ if (StringUtils.isEmpty(path)) {
|
|
|
|
+ path = DEFAULT_PATH;
|
|
|
|
+ }
|
|
|
|
+ is = this.getClass().getClassLoader().getResourceAsStream(path);
|
|
|
|
+ // File file = new File(path);
|
|
|
|
+ // File file = new File(this.getClass().getResource(path).getFile());
|
|
|
|
+ // is = new FileInputStream(file);
|
|
|
|
+ if (is == null) {
|
|
|
|
+ throw new RuntimeException(path + ".......文件未找到!!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ addFileContents(is, fileContents);
|
|
|
|
+ } catch (Exception ioe) {
|
|
|
|
+ System.err.println("读取文件" + path + "出错.......................");
|
|
|
|
+ ioe.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ this.close(is);
|
|
|
|
+ }
|
|
|
|
+ return fileContents;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void addFileContents(InputStream is, List<String> fileContents) throws Exception {
|
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"), 512);
|
|
|
|
+
|
|
|
|
+ EncrypDES encrypDES = new EncrypDES();
|
|
|
|
+ String theWord = null;
|
|
|
|
+ int i = 0;
|
|
|
|
+ do {
|
|
|
|
+ theWord = br.readLine();
|
|
|
|
+ if (theWord != null && !"".equals(theWord.trim())) {
|
|
|
|
+ if (i == 5) {
|
|
|
|
+ logger.info("读取文件第六行解密前:" + theWord.trim());
|
|
|
|
+ logger.info("读取文件第六行解密后:" + encrypDES.decryptor(theWord.trim()));
|
|
|
|
+ }
|
|
|
|
+ fileContents.add(encrypDES.decryptor(theWord.trim()));
|
|
|
|
+ }
|
|
|
|
+ i++;
|
|
|
|
+ } while (theWord != null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
public void writeFileContents(List<String> contents, String path) {
|
|
public void writeFileContents(List<String> contents, String path) {
|
|
this.writeFileContents(contents, path, "");
|
|
this.writeFileContents(contents, path, "");
|
|
}
|
|
}
|
|
|
|
|
|
public void writeFileContents(List<String> contents, String path, String separator) {
|
|
public void writeFileContents(List<String> contents, String path, String separator) {
|
|
- if (!StringUtils.isEmpty(path_prefix)) path = path_prefix + path;
|
|
|
|
|
|
+ if (!StringUtils.isEmpty(path_prefix)) {
|
|
|
|
+ path = path_prefix + path;
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
FileWriter fw = new FileWriter(path);
|
|
FileWriter fw = new FileWriter(path);
|
|
for (String content : contents) {
|
|
for (String content : contents) {
|