# Saving a list of points into a text file

I recently posted a question about this, but was not really sure where to go. I've gotten some progress, and have generated some simple noise here:

http://pastie.org/5408655

That works well enough for me, but I would really like to be able to save the points into an ascii text file. currently it's formatted so that something like this:

11111111

11111111

11111111

11111111

would create a square. I need to save in this format with the points(and lines connecting them) generated in the method above.

Essentially, I need to write the array of points created in the first example to a text file formatted like the second example. EDIT: I ended up using serialization. This method makes it un-editable, but works for my purposes, I can really have good terrain generation now. here's my code: http://pastie.org/5455624 Everything is working excellently. Thanks to all those who helped

• Your question, if I'm interpreting it correctly, is: "how do I write a text file from Java?" Is that correct? – Trevor Powell Nov 21 '12 at 4:20
• No, not exactly. I need to write an array of points into a text file in the format used in my example. Edited for clarity. – Dylan Katz Nov 21 '12 at 4:28
• How do your points look like then? I mean, do you have Java classes for them? Maybe a bit code would help. – Markus Nov 21 '12 at 7:47
• What do you mean? I put the code in the post. The class "Point" is built in to java. – Dylan Katz Nov 21 '12 at 20:50
• Paste your solution as an answer and accept it. Maybe someone can make use of it later. – Anko Dec 9 '12 at 1:06

You could consider Serialization