I am trying to implement meeting scheduling algorithm. I want to randomly generate meetings and store it in a file. Then read this file in another code, create different agents who will try to schedule these meetings.
My input meeting file is as follows:
1 20 25 [1 2 3 4 5] [4 5]
2 21 29 [1 6 7 5 33] [1 5 33]
from left to right, these values indicate meeting id, start time, hard deadline, attendees ID list, Essential attendees ID list.
Basically it is combination of integers and integer arraylist(dynamic,size not fixed).
To store this, I have used this code
File fleExample = new File("Meeting.txt")
PrintWriter M1 = new PrintWriter(fleExample);
M1.print(m.getMeetingID()+" "+m.getStartTime()+" "+m.getHardDeadLine()+" "+m.getAttendees()+" "+m,getEssentialAttendees());
M1.println();
I want to read these values and set it to integer variables and integer arraylist.
FileInputStream fstream = new FileInputStream("Meeting.txt");
DataInputStream inp = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(inp));
String strLine;
while ((strLine = br.readLine()) != null) {
String[] tokens = strLine.split(" ");
for (int i = 0; i < MeetingCount; i++) {
Meeting meet = new Meeting();
meet.setMeetingID(Integer.valueOf(tokens[0]));
meet.setStartTime(Integer.valueOf(tokens[1]));
meet.setHardDeadLine(Integer.valueOf(tokens[2]));
}
}
I am able to set the values to integers but could not find a way to do the same for arraylist.I want to do store the string to arraylist. Any help in this direction will be great.