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());

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();

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.

Why re-invent the wheel?
Why not use ObjectOutputStream and ObjectInputStream to write your meeting data as Java objects and read them in the same way? If there's a top-level object that holds the whole list of meetings then you can just write/read that as a single object.
Alternatively, if your own classes conform to normal JavaBean protocols (getters setters etc) you can use XMLEmcode/XMLDecode to convert the whole shebang to/from XML and write that to a text file

you don't know how to store a String in an arraylist?

List<String> arrayList = new ArrayList<String>();

if it's something else that's bugging you, could you be a bit more specific?

Hi, I think you are not getting the problem. I am trying to design a simulation for meeting scheduling. I want to store these randomly generated meetings once and then if I change some property of Person class, I want to analyse the effect on my algorithm without changing the input set(Meetings).

I have figured out a way by spliting it in different files, integers in one file and arraylist in another. Then it becomes easier to read.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.