diff --git a/src/main/java/com/loafle/overflow/crawler/wmi/WMICrawlerLinux.java b/src/main/java/com/loafle/overflow/crawler/wmi/WMICrawlerLinux.java index b8a8325..c2ee7da 100644 --- a/src/main/java/com/loafle/overflow/crawler/wmi/WMICrawlerLinux.java +++ b/src/main/java/com/loafle/overflow/crawler/wmi/WMICrawlerLinux.java @@ -110,7 +110,7 @@ public class WMICrawlerLinux extends WMICrawlerOS { continue; } - row = new ArrayList<>(); + row = new ArrayList<>(Arrays.asList(new String[metaMap.size()])); String[] datas = line.split(DELIMITER_SPLIT); @@ -118,8 +118,8 @@ public class WMICrawlerLinux extends WMICrawlerOS { tempMap.put(columns.get(indexJ), datas[indexJ]); } - for(String key : metaMap.keySet()) { - row.add(tempMap.get(key)); + for (Map.Entry info : metaMap.entrySet()) { + row.set(info.getValue().intValue(), tempMap.get(info.getKey())); } diff --git a/src/main/java/com/loafle/overflow/crawler/wmi/WMICrawlerWindows.java b/src/main/java/com/loafle/overflow/crawler/wmi/WMICrawlerWindows.java index c974ae5..123c758 100644 --- a/src/main/java/com/loafle/overflow/crawler/wmi/WMICrawlerWindows.java +++ b/src/main/java/com/loafle/overflow/crawler/wmi/WMICrawlerWindows.java @@ -10,10 +10,7 @@ import com.loafle.overflow.crawler.config.Query; import com.loafle.overflow.crawler.result.OFResultSet; import com.loafle.overflow.crawler.result.OFResultSetCol; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * Created by snoop on 2017-04-11. @@ -62,16 +59,16 @@ public class WMICrawlerWindows extends WMICrawlerOS { while (enumVariant.hasMoreElements()) { - row = new ArrayList<>(); + row = new ArrayList<>(Arrays.asList(new String[metaMap.size()])); vItem = enumVariant.nextElement(); item = vItem.toDispatch(); - for( String key : metaMap.keySet()) { - vValue = Dispatch.call(item, key); + for (Map.Entry info : metaMap.entrySet()) { + vValue = Dispatch.call(item, info.getKey()); value = vValue.toString(); vValue.safeRelease(); - row.add(value); + row.set(info.getValue().intValue(), value); } vItem.safeRelease();