There is a task: you need to organize work with an associative array in java using Map. Namely, there are 2 files with entries: a key and a value type. The key needs to be output to 3 files, the result on keys 2 and 5. I figured out how to create a map, but how to read data from files, exactly so that the key value is written first, and after reading the file, the next one is written in the reverse order. After all, when declaring a map, the type of key and the contents in it are specified, but first this number and letter, and then in the second file the letter, the number are the files and data:
1.txt
1 a 2 v 3 f 4 g
2.txt
k 6 b 3 n 5 m 7
result.txt
2 5
package task; import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; public class task1_collections { private InputStream input; private OutputStream out; String line; Map<int, String> map1 = new HashMap<int, String>(); Map<String, int> map1 = new HashMap<String, int>(); }
Still eclipses swears and does not allow to set the whole and. but only the string and the string how to count from the files in the map and did not figure out