开发者

Matching filenames with id

开发者 https://www.devze.com 2023-01-05 13:23 出处:网络
I have 1 text file which contains numbers from 1 to 11644. Beside the numbers are the names of the xml files that i have in another folder. I have a total of 8466 xml files. I need to match the filena

I have 1 text file which contains numbers from 1 to 11644. Beside the numbers are the names of the xml files that i have in another folder. I have a total of 8466 xml files. I need to match the filename of all the xml files with the id in the text file and extract the value of the id out. All of the id are in random position. An example would be my first xml file id is 7025, which means it's id is 7025. I'm new to java so i really开发者_运维知识库 hope someone would enlighten me thanks.


The data structure for this is a map.

Read in the input file, and add each line to a java.util.HashMap<String, Integer>. The key should be the filename. The value should be the id. Thus, for each line, myMap.put(filename, id). Now, when you want to check the ID of a file, do myMap.get(filename). It will return the Integer ID of the file.

0

精彩评论

暂无评论...
验证码 换一张
取 消