Results 1 to 4 of 4
- 01-30-2008, 05:39 AM #1
Member
- Join Date
- Jan 2008
- Posts
- 5
- Rep Power
- 0
- 01-30-2008, 06:32 AM #2
1. Open file using output stream of your choice.
2. Loop through each elements in your list
3. For what ever there is in the list get the string or other native types and write to output stream.
Done.. Hope it helps..dont worry newbie, we got you covered.
- 01-30-2008, 06:39 AM #3
Member
- Join Date
- Jan 2008
- Posts
- 5
- Rep Power
- 0
Here's what I have, but doesn't seem to work :confused:
Java Code:public static ArrayList writeAccts(ArrayList anAL, String file) { Writer output = null; try { output = new BufferedWriter( new FileWriter(file) ); output.write(anAL); } finally { if (output != null) output.close(); } return anAL; }
- 01-30-2008, 06:53 AM #4
Take care of exceptions in the code above as well ..Java Code:try { output = new BufferedWriter(new FileWriter(file)); //output.write(anAL); for (Iterator elementsInList = anAL.iterator(); elementsInList.hasNext();) { <WHAT IS IN THE LIST> element = (<WHAT IS IN THE LIST>) elementsInList.next(); output.write(<GET/MAKE String thing from your element>); } } finally { if (output != null) output.close(); }dont worry newbie, we got you covered.
Similar Threads
-
how to write onto a file
By mirage_87 in forum New To JavaReplies: 6Last Post: 09-08-2009, 03:54 PM -
a simple code (cldc or midp) to write a text file ouside of the application package
By sina in forum CLDC and MIDPReplies: 3Last Post: 12-12-2008, 12:12 PM -
File Write Error
By vikain in forum Advanced JavaReplies: 5Last Post: 01-02-2008, 04:38 AM -
Write unicode into file
By vata2999 in forum New To JavaReplies: 1Last Post: 08-08-2007, 03:04 PM -
Help with write file in java
By mathias in forum New To JavaReplies: 1Last Post: 07-31-2007, 06:51 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks