Thread: Array storage
View Single Post
  #7 (permalink)  
Old 04-17-2008, 08:18 AM
Eranga's Avatar
Eranga Eranga is offline
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,543
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Here is a simple way that how to write array elements to a text file

Code:
public class ArrayToFile { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here String[] numbers = {"One", "Two", "Three", "Four", "Five"}; int i = 0; FileWriter fw = null; try { fw = new FileWriter("test.txt"); BufferedWriter out = new BufferedWriter(fw); while(i < numbers.length){ out.write(numbers[i]); out.newLine(); i++; } out.close(); } catch (IOException ex) { System.out.println(ex.getLocalizedMessage()); } } }
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote