-
best way for I/O
Hey, been a long time since I've been on here. Been a long time (I'd say 8 months) since I've truly dealt with java. Before I briefly stopped with it, I never truly grasped file I/O.
so, whats the best way to implement it?
im doing a little project (for myself) which deals with everything I learned (besides applets) and Im now stuck on the I/O.
My goal is to be able to write files with several lines in them and be able to read each file seperately
*OR*
Write one file and keep adding to it and when I read it I can just scroll through it.
thanks
-
Re: best way for I/O
Depends on your application.
What does your program do? Does it make sense to split the files up, or is having a single file advantageous?
-
Re: best way for I/O
Yeah it really depends upon what you are trying to do. File IO is expensive so reading an writing to files 100 of times a minute is a bad idea. If at all possible you should try to read once and write once. Keep the contents of the file in memory and manipulate it as much as you like and then when you are done write it back to the file. However if the file is extremely large then you may run out of memory. But the principal remains: reduce the amount of IO as much as possible.
-
Re: best way for I/O
Ok, well it would only read or write once every time the program is run. The program would kind of be like a log. You know, like "this happened on this date at this time". So if it were all one file then you could scroll through all the posts, if not thenb you would have to call those files by date or what not.