Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
    
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
    
Ok, I have it properly generated, thanks :) –  Dylan Katz Nov 22 '12 at 19:37
show 2 more comments

1 Answer

up vote 3 down vote accepted

You could consider Serialization

http://www.tutorialspoint.com/java/java_serialization.htm

Advantages

  1. Hides your values
  2. Easier to save/load

Disadvantages

  1. Values can not be modified in text editor.
share|improve this answer
    
Did that, worked excellently! Thank you so much! –  Dylan Katz Nov 23 '12 at 18:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.