1010import weka .core .Attribute ;
1111import weka .core .Instances ;
1212import weka .core .converters .ArffSaver ;
13-
1413import java .io .File ;
15- import java .io .FileInputStream ;
1614import java .io .FileReader ;
1715import java .io .IOException ;
16+ import java .nio .file .Files ;
17+ import java .nio .file .Paths ;
1818import java .util .*;
1919import java .util .zip .ZipEntry ;
2020import java .util .zip .ZipInputStream ;
@@ -113,7 +113,7 @@ public static Map<String, String> getAllClassesFromDir(String dir) throws IOExce
113113
114114 private static Set <String > getAllClassesFromJar (String jarFile ) throws IOException {
115115 Set <String > classes = new HashSet <>();
116- ZipInputStream zip = new ZipInputStream (new FileInputStream ( jarFile ));
116+ ZipInputStream zip = new ZipInputStream (Files . newInputStream ( Paths . get ( jarFile ) ));
117117 for (ZipEntry entry = zip .getNextEntry (); entry != null ; entry = zip .getNextEntry ()) {
118118
119119 if (!entry .isDirectory () && entry .getName ().endsWith (".class" )) {
@@ -239,6 +239,7 @@ public static Set<String> getFiles(String fileInDirectory) throws IOException {
239239 Set <String > files = new HashSet <>();
240240 File folder = new File (directory );
241241 File [] listOfFiles = folder .listFiles ();
242+ assert listOfFiles != null ;
242243 for (File listOfFile : listOfFiles ) {
243244 if (listOfFile .isFile () && listOfFile .getName ().endsWith (".txt" )
244245 && !listOfFile .getName ().endsWith ("_" + Category .NONE + ".txt" )
@@ -294,7 +295,7 @@ public static String getClassName(Instances instances) {
294295 *
295296 * @param instances WEKA instances to be exported
296297 */
297- public static String exportInstancesToArff (Instances instances , String source ) {
298+ public static String exportInstancesToArff (Instances instances , String fileName ) {
298299 ArffSaver saver = new ArffSaver ();
299300
300301 if (SwanPipeline .options .isExportArffData () && !SwanPipeline .options .getOutputDir ().isEmpty ()) {
@@ -308,7 +309,7 @@ public static String exportInstancesToArff(Instances instances, String source) {
308309 if (instances .relationName ().contains (":" ))
309310 relationName = relationName .substring (0 , instances .relationName ().indexOf (":" ));
310311
311- String arffFile = SwanPipeline .options .getOutputDir () + File .separator + "arff-data" + File .separator + relationName + "-" + source + ".arff" ;
312+ String arffFile = SwanPipeline .options .getOutputDir () + File .separator + "arff-data" + File .separator + fileName + ".arff" ;
312313 saver .setFile (new File (arffFile ));
313314 saver .writeBatch ();
314315 } catch (IOException e ) {
0 commit comments