@@ -76,7 +76,7 @@ public void mergeAction() throws Exception { //合并操作
7676 } else if (fileTypeSelectIndex == 1 ) {
7777 mergeCsv (fileList , newFilePath );
7878 } else if (fileTypeSelectIndex == 2 ) {
79- mergeFile ();
79+ mergeFile (fileList , newFilePath );
8080 }
8181 }
8282
@@ -159,32 +159,7 @@ public void mergeCsv(List<File> fileList, String newFilePath) throws Exception {
159159 printer .close ();
160160 }
161161
162- public void mergeFile () throws Exception {
163- String filePath = fileMergeToolController .getSelectFileTextField ().getText ();
164- String [] filePaths = filePath .split ("\\ |" );
165- List <File > fileList = new ArrayList <>();
166- for (String path : filePaths ) {
167- File file = new File (path );
168- if (file .isDirectory ()) {
169- fileList .addAll (Arrays .asList (file .listFiles ()));
170- } else {
171- fileList .add (file );
172- }
173- }
174- String newFilePath = null ;
175- if (fileList .get (0 ).isDirectory ()) {
176- if (StringUtils .isNotEmpty (fileMergeToolController .getSaveFilePathTextField ().getText ())) {
177- newFilePath = StringUtils .appendIfMissing (fileMergeToolController .getSaveFilePathTextField ().getText (), "/" , "/" , "\\ " ) + "merge_file" ;
178- } else {
179- newFilePath = fileList .get (0 ).getPath () + "/merge_file.txt" ;
180- }
181- } else {
182- if (StringUtils .isNotEmpty (fileMergeToolController .getSaveFilePathTextField ().getText ())) {
183- newFilePath = StringUtils .appendIfMissing (fileMergeToolController .getSaveFilePathTextField ().getText (), "/" , "/" , "\\ " ) + "merge_" + fileList .get (0 ).getName ();
184- } else {
185- newFilePath = fileList .get (0 ).getParent () + "/merge_" + fileList .get (0 ).getName ();
186- }
187- }
162+ public void mergeFile (List <File > fileList , String newFilePath ) throws Exception {
188163 File resultFile = new File (newFilePath );
189164 try {
190165 FileChannel resultFileChannel = new FileOutputStream (resultFile , true ).getChannel ();
0 commit comments