• Post Reply Bookmark Topic Watch Topic
  • New Topic

Designing Address Book Using File IO - Suggestion Required  RSS feed

 
Ben Prequel
Greenhorn
Posts: 19
Chrome IntelliJ IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I am very new to Java. I just finished reading a bit about File IO. Now i have decided to make my hands dirty with some practical example.
I have thought of a very common use-case. An address book application. Here are the functionality.

  • It's a console based application. For the input from console, i would be using Console class.
  • It will have following operations. Add/Delete/Search/View/Exit
  • What type of File class i can use for this special purpose? How can i store the data that i can easily read it and view?


  • Mostly people use CSV format, but i am not at that advance level yet. It's a beginner's application. Can someone suggest?

    Thanks,
    Ben
     
    Campbell Ritchie
    Marshal
    Posts: 56536
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ben Prequel wrote: . . . i would be using Console class. . . .
    Beware. If you use javaw to open an executable .jar file, there is no Console object available and any use of it is liable to cause a NullPointerException.
     
    Ben Prequel
    Greenhorn
    Posts: 19
    Chrome IntelliJ IDE Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Dear Campbell,

    Thanks for your valuable input. I will keep it in mind. So in this case, what can be the alternative, if we have to package it as a jar.
    On the other hand, what can you advice about my points?

    Thanks,
    Ben
     
    Campbell Ritchie
    Marshal
    Posts: 56536
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    If you don't have a Console object, you cannot run it as a console application. You would have to use GUI components; the simplest (but old‑fashioned) might be JOptionPane.
     
    Ben Prequel
    Greenhorn
    Posts: 19
    Chrome IntelliJ IDE Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Dear Campbell,

    Thanks for your answer. I understood the concept what you are trying to explain.

    Actually, i am trying to develop first time an application of address book which will be purely designed using File IO. I am trying to understand the
    concepts regarding it. This will have an ADD/DELETE/SEARCH/View functionality. What kind of IO stream would be used? I searched and there is something
    called RandomAccessFile. Will that be helpful?

    Thanks,
     
    Junilu Lacar
    Sheriff
    Posts: 11481
    180
    Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ben Prequel wrote:Actually, i am trying to develop first time an application of address book which will be purely designed using File IO.

    File I/O is an infrastructure service. If you try to design your program from the bottom up like this, you'll get bogged down in the implementation before you've even had a chance to think logically about the different concepts involved. It's like designing a house by starting with the design of the pipes and plumbing system.

    A top-down approach starting with a conceptual design is a better way to start. It doesn't have to be elaborate or detailed but it should include the major concepts and behaviors that you want.

    If you just want to apply what you learned about File I/O, I suggest you write a very *small* sample program instead. You don't need to write an entire address book program.
     
    Campbell Ritchie
    Marshal
    Posts: 56536
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I am not convinced that File IO is a very efficient way to implement an address book. If you have a 1000‑entry file and you want to delete entry 298, you will have to copy the other 999 and write them anew.
    Junilu is right: start with the concepts.
     
    Ben Prequel
    Greenhorn
    Posts: 19
    Chrome IntelliJ IDE Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Dear Junilu and Campbell,

    Thanks for both of your suggestion. I totally agree, i should start with small concepts. Thankyou very much. I would start with
    it right away and quote my issues if i come across any.

    Regards,
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!