
I am trying to save the data from file to a map, then iterate through map and write it to a separate file.My data looks like this:
Concept:Conferences:conferences:confID Concept:Organizations:organizations:orgID Property:conferencesName:namespace:conferences.Name Property:conferencesDate:namespace:conferences.Date
Here are the steps that I did and planning to perform:
Next step would be to create a method that write the lines below into a separate file that already exists in computer. map: a d2rq:ClassMap;
map: a d2rq:PropertyBridge;
The last step would be to iterate through the maps and if it is a concept map write the "key" into the "blank (line 1)" above in step 2 and vice versa for property.
I am new to programming and kind of stuck with steps 2 and 3. Can somebody help me! Please find my code for step 1 here
import java.io.*;
import java.util.*;
public class ReadAndStoreManual {
public static void main(String[] args) {
Map<String, List<String>> conceptMap = new HashMap<String, List<String>>();
Map<String, List<String>> PropertyMap = new HashMap<String, List<String>>();
try{
Scanner scanner = new Scanner(new FileReader("C:/"));
while (scanner.hasNextLine()){
String nextLine = scanner.nextLine();
String [] column = nextLine.split(":");
if (column[0].equals ("Concept")){
if (column.length == 4) {
PropertyMap.put(column [1], Arrays.asList(column[2], column[3]));
}
else {
conceptMap.put (column [1], Arrays.asList (column[2], column[3]));
}
}
}
scanner.close();
}
catch (Exception e) {
e.printStackTrace();
}
System.out.println(conceptMap);
System.out.println(PropertyMap);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.