Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: Java array writing in seperate files

  1. #1
    Member
    Join Date
    Sep 2013
    Posts
    51
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Java array writing in seperate files

    I've got a array of objects and want to write each object in a seperate file. I've tryed to do this with a FileOutputStream and nio but it was too slow. Is there a better way to do this? It should also be readable.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Java array writing in seperate files

    What do you mean by "too slow"? What are you comparing the times with?

    Can you make a small, simple program that compiles, executes and shows what you are trying to do?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Sep 2013
    Posts
    51
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Java array writing in seperate files

    Well, what's the best way to write each object in an array to a seperate file?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Java array writing in seperate files

    use a loop
    get next object from array
    create file for that object
    write that object to its file
    close the file
    end loop
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Sep 2013
    Posts
    51
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Java array writing in seperate files

    I already did that. I mean the best file writing method for a lot of objects. The output method itself, not the loop.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Java array writing in seperate files

    For writing objects I've used writeObject().
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Member
    Join Date
    Sep 2013
    Posts
    51
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Java array writing in seperate files

    What class is it in?

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Java array writing in seperate files

    ObjectOutputStream
    If you don't understand my answer, don't ignore it, ask a question.

  9. The Following User Says Thank You to Norm For This Useful Post:

    Bingo90 (October 21st, 2013)

  10. #9
    Member
    Join Date
    Sep 2013
    Posts
    51
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Java array writing in seperate files

    Ok thank you

Similar Threads

  1. Reading files and writing files
    By ProgrammerNewbie in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 3rd, 2012, 12:13 AM
  2. toString not printing everything in the Array which is in a seperate class
    By taz_1891 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: September 30th, 2012, 11:51 AM
  3. FileWrite Over-Writing txt Files. D:
    By Java Programmer in forum What's Wrong With My Code?
    Replies: 10
    Last Post: January 8th, 2012, 04:31 PM
  4. Reading In Then Writing Out Massive Files
    By aussiemcgr in forum Java Theory & Questions
    Replies: 3
    Last Post: July 28th, 2011, 07:00 PM
  5. Writing to files
    By nitwit3 in forum Java Theory & Questions
    Replies: 3
    Last Post: July 25th, 2011, 04:00 AM