Connect with Facebook Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Java Help

Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-19-2008, 03:10 PM
Turk4n's Avatar   
Code Warrior
 
Join Date: May 2008
Location: 4chan.org/g/
Age: 19
Posts: 2,714
Blog Entries: 4
Rep Power: 29
Turk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to behold
Send a message via MSN to Turk4n Send a message via Skype™ to Turk4n
Default Hey C.C, long time no see !

Well first post since a long time. Anyways I need help with, how do I create an ArrayList that saves every element to a file?
I have created an ArrayList and it is functional, however how do I make it save the elements to a file?
Anyone that could provide some tips and help for me?
Thanks in advance guys !
__________________
Quote:
Originally Posted by Turk4n
The Last man who laughs, he did not get the joke.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-19-2008, 04:05 PM
chili5's Avatar   
Code Warrior
 
Join Date: Mar 2008
Posts: 5,462
Blog Entries: 3
Rep Power: 49
chili5 is a splendid one to beholdchili5 is a splendid one to beholdchili5 is a splendid one to beholdchili5 is a splendid one to beholdchili5 is a splendid one to beholdchili5 is a splendid one to beholdchili5 is a splendid one to behold
Default Re: Hey C.C, long time no see !

Um I haven't tried this but try:

Code:
PrintWriter fout = new PrintWriter(new FileWriter("OUT.txt"));
for (int index=0;index<arlNums.size();index++) {
fout.println(arlNums.get(index));
}
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-20-2008, 12:48 AM
Turk4n's Avatar   
Code Warrior
 
Join Date: May 2008
Location: 4chan.org/g/
Age: 19
Posts: 2,714
Blog Entries: 4
Rep Power: 29
Turk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to behold
Send a message via MSN to Turk4n Send a message via Skype™ to Turk4n
Default Re: Hey C.C, long time no see !

Quote:
Originally Posted by chili5 View Post
Um I haven't tried this but try:

Code:
PrintWriter fout = new PrintWriter(new FileWriter("OUT.txt"));
for (int index=0;index<arlNums.size();index++) {
fout.println(arlNums.get(index));
}
Ok, going to try and need to rush out now, thanks for your help !
__________________
Quote:
Originally Posted by Turk4n
The Last man who laughs, he did not get the joke.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-20-2008, 05:40 AM
chili5's Avatar   
Code Warrior
 
Join Date: Mar 2008
Posts: 5,462
Blog Entries: 3
Rep Power: 49
chili5 is a splendid one to beholdchili5 is a splendid one to beholdchili5 is a splendid one to beholdchili5 is a splendid one to beholdchili5 is a splendid one to beholdchili5 is a splendid one to beholdchili5 is a splendid one to behold
Default Re: Hey C.C, long time no see !

Yeah just tried it, and it's working great.

Code:
import java.util.*;
import java.io.*;
public class al {
    public static void main(String[] args) throws IOException {
        Scanner fin = new Scanner(new FileReader("data.txt"));
        PrintWriter fout = new PrintWriter(new FileWriter("OUT.txt"));
        ArrayList alnNums = new ArrayList<Integer>();
        
        while (fin.hasNextInt()) {
            alnNums.add(fin.nextInt());
        }

        for (int index=0;index<alnNums.size();index++) {
            fout.println(alnNums.get(index));
        }

        fout.close();
        fin.close();
    }

}
That does work. Hope it helps.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-20-2008, 08:16 AM
Turk4n's Avatar   
Code Warrior
 
Join Date: May 2008
Location: 4chan.org/g/
Age: 19
Posts: 2,714
Blog Entries: 4
Rep Power: 29
Turk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to behold
Send a message via MSN to Turk4n Send a message via Skype™ to Turk4n
Default Re: Hey C.C, long time no see !

Yep works and thanks
__________________
Quote:
Originally Posted by Turk4n
The Last man who laughs, he did not get the joke.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-20-2008, 01:59 PM
Xav's Avatar   
Xav Xav is offline
Code Slinger
 
Join Date: Mar 2008
Location: The North Pole
Posts: 13,210
Blog Entries: 13
Rep Power: 105
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: Hey C.C, long time no see !

Long time no see, Turk4n? How are you?
__________________

Quote:
Originally Posted by Jordan View Post
Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 11-21-2008, 12:27 PM
Turk4n's Avatar   
Code Warrior
 
Join Date: May 2008
Location: 4chan.org/g/
Age: 19
Posts: 2,714
Blog Entries: 4
Rep Power: 29
Turk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to behold
Send a message via MSN to Turk4n Send a message via Skype™ to Turk4n
Default Re: Hey C.C, long time no see !

Quote:
Originally Posted by Xav View Post
Long time no see, Turk4n? How are you?
Had better days, and those days :'(
__________________
Quote:
Originally Posted by Turk4n
The Last man who laughs, he did not get the joke.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 11-21-2008, 12:45 PM
Xav's Avatar   
Xav Xav is offline
Code Slinger
 
Join Date: Mar 2008
Location: The North Pole
Posts: 13,210
Blog Entries: 13
Rep Power: 105
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: Hey C.C, long time no see !

Lol you must be getting pretty advanced with Java, then?
__________________

Quote:
Originally Posted by Jordan View Post
Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 11-21-2008, 04:39 PM
Turk4n's Avatar   
Code Warrior
 
Join Date: May 2008
Location: 4chan.org/g/
Age: 19
Posts: 2,714
Blog Entries: 4
Rep Power: 29
Turk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to beholdTurk4n is a splendid one to behold
Send a message via MSN to Turk4n Send a message via Skype™ to Turk4n
Default Re: Hey C.C, long time no see !

Quote:
Originally Posted by Xav View Post
Lol you must be getting pretty advanced with Java, then?
Well hopefully, before my death I would like to be pro in something
__________________
Quote:
Originally Posted by Turk4n
The Last man who laughs, he did not get the joke.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 11-21-2008, 10:31 PM
Newbie
 
Join Date: Nov 2008
Posts: 2
Rep Power: 0
eva6206213 is an unknown quantity at this point
Default Re: Hey C.C, long time no see !

Thank you for the info~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! Rlink32 Error Sparky Pascal/Delphi 6 10-16-2008 10:31 AM
How to add My program to Startup ? kresh7 Visual Basic Programming 49 09-14-2008 11:13 AM
First post from long time Ccal lurker James Argo Introductions 7 07-22-2008 04:41 PM
SecurityAudit vinay Visual Basic Programming 27 01-07-2008 12:14 PM


All times are GMT -5. The time now is 08:23 PM.

Freelance Jobs

XML/XSL: Need code for Book with Chapers using XML
Create an XML file for a book of your creation, and a basic CSS file that will format it to display ...
Earn: $40.00


C++/C: Simple firework cue sequencer
What I require is a rework of a simple cue sequencer. I have a piece of hardware (an Arduino boar...
Earn: $50.00


HTML/XHTML: Menu Rework - ASCIIBin
I'm placing this in the HTML/XHTML section of the Freelance site but you are not limited to HTML. Wh...
Earn: $20.00



CodeCall Goal

Goal #1: 1,000 Blogs
Goal #2: 1,000 Wiki Pages
Goal #3: 300,000 Posts
Goal #4: 20,000 Threads
Done: 30%, 23%, 55%, 75%

Ads