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

Thread: hi, i am finding dificulties understanding this question pls help

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default hi, i am finding dificulties understanding this question pls help

    Write a program in Java that will take in two files file as parameters and generate a series of files depending on how many records are in the 2nd file.
    Copies of the two files are in Appendix A & Appendix B

    Appendix A
    File 1
    SOFTPLUS
    2 Sangarah Close
    Labone
    P.O. Box 3856
    Accra North

    Dear ???,

    RE: Graduate Entry Placement
    Thank you for applying for the position of ???? at SOFTPLUS in our ???? department. SOFTPLUS will like to invite you to attend an interview for the position. Your interview will be scheduled for ????. Please bring your CV. After your formal interview you would be required to sit a 1hr technical paper.
    Please contact our Human Resources department if you have any problems or require further information.

    Yours Sincerely
    quojo


    Appendix B
    File 2
    John Diamond, Oracle Dba, System Admin , May 21 2014
    William Nettey, Junior Developer , IT Support , May 21 2014
    Janet Owusu , Business Analyst , Credits , May 28 2014
    Kofi Neequaye, Linux Administrator, , System Admin , May 21 2014
    Naa-Dei Thompson, Business Analst, Risks, May 28 2014


    import java.io.File;
    import java.io.IOException;
    import java.io.FileWriter;
    import java.io.BufferedWriter;
    //import java.io.BufferedReader;

    public class file {

    public static void main(String[] args) {

    //File fileA =null;
    // File fileB =null;

    try{

    String Awords = " This is the life ";

    String Bwords = " The jave rock the life ";


    File fileA = new File("Appx A.txt");
    File fileB = new File("Appx B.txt");

    if(fileA.createNewFile()& fileB.createNewFile())
    System.out.println("Success!");
    else
    System.out.println
    ("Error, file already exists.");

    FileWriter riteA = new FileWriter(fileA.getAbsoluteFile());
    FileWriter riteB = new FileWriter(fileB.getAbsoluteFile());

    BufferedWriter Arite = new BufferedWriter(riteA);
    BufferedWriter Brite = new BufferedWriter(riteB);

    Arite.write(Awords);
    Brite.write(Bwords);

    Arite.close():
    Brite.close();

    }
    catch(IOException ioe) {
    ioe.printStackTrace();
    }
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: hi, i am finding dificulties understanding this question pls help

    That's hard to understand. I have no idea what is being asked.
    Are you sure you translated the assignment to English correctly?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: hi, i am finding dificulties understanding this question pls help

    sorry about the typing mistake pls

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: hi, i am finding dificulties understanding this question pls help

    The assignment is to read two files, one the form letter template and the other the data that is to be merged into the letter template. The skills required are to read the files, merge the data read from the files, and generate the letters, either output to another file or files or to the screen. Which of these skills do you need help with? Show what you've tried for any of the necessary steps.

  5. #5
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: hi, i am finding dificulties understanding this question pls help

    i have updated it with the codes i wrote but am not getting the merging part
    pls check and help me out
    i want to merge AppxB with AppxA

  6. #6
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: hi, i am finding dificulties understanding this question pls help

    There are several approaches, and coding each of them will depend to some degree on how you've stored the file that contains the body of the message or the letter.

    In general:

    1. Read the file that contains the body of the letter and store it in a convenient way. The definition of "convenient" may depend on what you choose to do next.

    2. Identify the '????' strings in the body of the message and replace each one in order with the 4 items in a single line of data items read from the second file.

    3. Output or save the result.

    4. Repeat until the end of the second file (the data) has been reached.

  7. #7
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: hi, i am finding dificulties understanding this question pls help

    how will i do that
    i wanted to use the file input and file output stream but dont know how to do that

  8. #8
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: hi, i am finding dificulties understanding this question pls help

    Use buffered file reader and writer and the String methods. You can find further info on both of those by searching for tutorials and using the appropriate API pages. You may also have info in your textbook and class notes or lectures that you can refer to. It should not be the first time you are seeing these topics, and if it is, then there's something wrong that we can't fix.

Similar Threads

  1. [SOLVED] Stack Memory question (understanding)
    By KAJLogic in forum Java Theory & Questions
    Replies: 24
    Last Post: January 5th, 2014, 02:39 PM
  2. Simple question pls help beginner learning java
    By DroidJava in forum Java Theory & Questions
    Replies: 2
    Last Post: November 12th, 2013, 01:04 AM
  3. Need Help PLS
    By HeavySky in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 29th, 2013, 11:51 AM
  4. question pls
    By amaliutz in forum Java Theory & Questions
    Replies: 6
    Last Post: February 2nd, 2011, 09:37 AM
  5. Pls Help
    By randika11 in forum JDBC & Databases
    Replies: 3
    Last Post: July 20th, 2010, 05:52 AM