Hi
I want to store variables in a text file (not as an object).my problem is that the class contains ArrayList of another type ,and I wrote one method to store the member variables of my class in "file.txt" ,but I don't really know how to write the ArrayList variable in the same file (actually in the same line in that file).
I think of writting another method that write the arrayList variable but how to point to the same file and to the appropriate line? and what about reading that field?

I want to store variables in a text file (not as an object)

Can you explain what you want to do?
Text files usually contain Strings. If you want to write values of some String variables to a file that should be no problem.
You won't be able to write an ArrayList variable because it is not a String. If the ArrayList contains Strings, then you could extract those Strings from the A..L.. and write those Strings to the file.

Could you explain the different sources of the Strings that you want to write to the file and in what order do you want to write them?

OK,I have 2 classes the first one is Student which contains an ArrayList of Enrollments (which records the mark of a course).
I want to store all information about each student on a line in the file.these information include the student's marks in every course as well as his name ,surname and ID.the mark field is in the Enrollments objects (ArrayList).
my problem is how to read all the information of the Enrollements using another method.the first method reads all info about student (name ,surname and ID) ,the second method should continue reading the file from the same position to read the marks of the current student.

I want to store all information about each student on a line in the file.

Chose a delimiter to separate the individual information Strings. Build a String for each student with the information bits separated by the delimiter and write it to the file.

continue reading the file from the same position

If you want to read from the file in several different methods (??? why)
you should create the class to do the reading and them pass a reference to that class object to all the methods that want to read from that file.

(??? why)

I thought that it would be the solution to this problem.
the delimiter may solve it and I am going to try that.
thank you.

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.