Results 1 to 5 of 5
  1. #1
    eel
    eel is offline Member
    Join Date
    Sep 2010
    Posts
    36
    Rep Power
    0

    Exclamation Help with PrintWriter code

    I have created a file with different fields such as name, student ID, house phone number and mobile phone number, etc. How do I make the field not appeared in the file when people don't enter anything for the field such as house phone number?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    make the field not appeared in the file
    What kind of "file" is it?
    If you are writing a number of fields to a disk file and want to leave one out because it is empty, then you need to decide what you want the file to contain to indicate a missing field. Do you need to indicate that there is a missing field?
    Does each field go a a separate line?
    Are there separators between the fields?

    Is there a program that reads the file and must know that one of the fields is missing? How will you tell that program which field is missing?

  3. #3
    eel
    eel is offline Member
    Join Date
    Sep 2010
    Posts
    36
    Rep Power
    0

    Default

    Such as for example:
    Name: dfsalk
    Student ID:dfsalk
    House Phone Number:dfsak
    Phone number:dfsalk

    When the person don't enter phone number, the file should look like this:
    Name:dfs
    Student ID:fdasfda
    Phone number:dfsalk

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    When you write out the lines in the file, your code should test if the data for a line is missing and NOT write out that line.
    pseudo code;
    if have data for line1
    write line1
    if have data for line2
    write line2

    etc for the rest of the lines

  5. #5
    eel
    eel is offline Member
    Join Date
    Sep 2010
    Posts
    36
    Rep Power
    0

Similar Threads

  1. PrintWriter doesnt work :(
    By Addez in forum New To Java
    Replies: 11
    Last Post: 01-17-2010, 05:59 PM
  2. Help with printwriter.
    By Addez in forum New To Java
    Replies: 2
    Last Post: 10-30-2009, 01:58 PM
  3. Unexpected characters using PrintWriter
    By mjwoodford in forum New To Java
    Replies: 1
    Last Post: 09-18-2009, 06:09 PM
  4. difference printwriter & out.println
    By tushar88 in forum Java Servlet
    Replies: 1
    Last Post: 03-10-2009, 05:15 AM
  5. Using Printwriter (java.io.*)
    By LifeWithJava in forum New To Java
    Replies: 3
    Last Post: 12-25-2008, 08:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •