Closed Thread
Page 1 of 5 123 ... LastLast
Results 1 to 10 of 48

Thread: Hey C.C, long time no see !

  1. #1
    Join Date
    May 2008
    Location
    Hell
    Posts
    3,851
    Blog Entries
    4
    Rep Power
    49

    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 !

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Mar 2008
    Posts
    7,144
    Rep Power
    86

    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));
    }

  4. #3
    Join Date
    May 2008
    Location
    Hell
    Posts
    3,851
    Blog Entries
    4
    Rep Power
    49

    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 !

  5. #4
    Join Date
    Mar 2008
    Posts
    7,144
    Rep Power
    86

    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.

  6. #5
    Join Date
    May 2008
    Location
    Hell
    Posts
    3,851
    Blog Entries
    4
    Rep Power
    49

    Re: Hey C.C, long time no see !

    Yep works and thanks

  7. #6
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    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

  8. #7
    Join Date
    May 2008
    Location
    Hell
    Posts
    3,851
    Blog Entries
    4
    Rep Power
    49

    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 :'(

  9. #8
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    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

  10. #9
    Join Date
    May 2008
    Location
    Hell
    Posts
    3,851
    Blog Entries
    4
    Rep Power
    49

    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

  11. #10
    eva6206213 is offline Newbie
    Join Date
    Nov 2008
    Posts
    2
    Rep Power
    0

    Re: Hey C.C, long time no see !

    Thank you for the info~

Closed Thread
Page 1 of 5 123 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Future long time member here
    By Bill_Bonham in forum Introductions
    Replies: 4
    Last Post: 06-07-2011, 06:23 PM
  2. howdy! long time listener first time caller
    By darkresearcher in forum Introductions
    Replies: 2
    Last Post: 05-31-2011, 04:20 PM
  3. Server Taking a Long time to Respond, RAM issue?
    By ibad in forum Computer Software/OS
    Replies: 8
    Last Post: 10-13-2010, 06:28 AM
  4. Why i need wait long time to download images?
    By mario in forum C# Programming
    Replies: 5
    Last Post: 04-13-2009, 03:52 AM
  5. First post from long time Ccal lurker
    By James Argo in forum Introductions
    Replies: 7
    Last Post: 07-22-2008, 02:41 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts