Hi, is there anybody here knows how to store arrays in a text file?

let's say the user inputs the id, name, and address and stores it on a text file then shows its output..

ex. 245656, John, 6534 Japan, Male.

something like that.

or anyone have a similar program that I can look unto and study it.

thanks.

Recommended Answers

All 5 Replies

did you Google
read write file java
yet?

one of the results returned is this: oracles tutorials on how to read and write files, with example code.

Hi, is there anybody here knows how to store arrays in a text file?

let's say the user inputs the id, name, and address and stores it on a text file then shows its output..

ex. 245656, John, 6534 Japan, Male.

something like that.

or anyone have a similar program that I can look unto and study it.

thanks.

adding to what stultuske said, once you know how to write to a file, its just a matter of iterating over your array using a for statement and writing each variable to its appropriate place, the trick though would be to only close the file after all writing has been done

I didn't understand the link and I just "wtf", I'm just a beginner actually and this is kinda broad for me. that's the only probleme..I don't have any clue how to start it. I know all of the for,if,if else etc etc.. but not this kind. I'm actually confused the only way I can learn is to see the program and study it and how it works. I'm a slow learner..:( can you guys make a short program for me to understand it, I'll really appreciate it or make it simple for me to understand..:(

there are short examples in that tutorial.
do you think it 'll be easier if we copy paste those here? the contents will remain the same. if you know your basics of OO and you read up a bit on the flow of working with files, you'll see that that tutorial is not difficult to follow, and to find a solution for your problem.

I didn't understand the link and I just "wtf", I'm just a beginner actually and this is kinda broad for me. that's the only probleme..I don't have any clue how to start it. I know all of the for,if,if else etc etc.. but not this kind. I'm actually confused the only way I can learn is to see the program and study it and how it works. I'm a slow learner..:( can you guys make a short program for me to understand it, I'll really appreciate it or make it simple for me to understand..:(

I don't see how you say you cant understand the java docs, have you read through them? i know some of the stuff to read gets boring but its all useful information, but if you really don't want to take the time to understand them(which will help you now and in the future) just do a google on 'write array to text file java' your first two results should answer your question i would post the link(s), but then i'd be condoning laziness lol ;)

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.