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 4 of 4

Thread: best way for I/O

  1. #1
    Member
    Join Date
    Jan 2011
    Location
    Phoenix
    Posts
    49
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default 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

  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default 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?

  3. #3
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,537
    My Mood
    Grumpy
    Thanks
    0
    Thanked 166 Times in 157 Posts

    Default 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.
    Improving the world one idiot at a time!

  4. #4
    Member
    Join Date
    Jan 2011
    Location
    Phoenix
    Posts
    49
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default 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.