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.
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.
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.
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.
Well, what's the best way to write each object in an array to a seperate file?
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.
I already did that. I mean the best file writing method for a lot of objects. The output method itself, not the loop.
For writing objects I've used writeObject().
If you don't understand my answer, don't ignore it, ask a question.
What class is it in?
ObjectOutputStream
If you don't understand my answer, don't ignore it, ask a question.
Bingo90 (October 21st, 2013)
Ok thank you