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: how to read and execute the whole .txt file

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to read and execute the whole .txt file

    i am a student and i'm working on my final project.
    i'm want to execute the whole .txt file using JOptionPane but instead of displaying the whole .txt file,my programe execute it line by line by clicking 'ok' button..please help..


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

    Default Re: how to read and execute the whole .txt file

    i'm want to execute the whole .txt file
    Can you explain what it means to "execute a txt file"?

    Post a few sample lines from a text file
    and show what happens when each line is "executed"

    Do you mean that you want the program to read the file a line at a time and display that line when a GUI button is pressed? Each button press will display the next line.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,163
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: how to read and execute the whole .txt file

    i want the dialog box display all the content in a single dialog box only...
    In the loop: Read the contents and add an endline character "\n" at the end of each line and concatenate the line to the String that is to be displayed in the dialog box.
    Display the String after the end of the loop has gotten all the lines.

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. How to skip and read lines in txt file
    By saran123 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: December 26th, 2012, 08:07 AM
  2. Replies: 0
    Last Post: November 13th, 2012, 07:02 AM
  3. Can't work out how to read object from .txt file
    By goformickey in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 25th, 2012, 01:27 AM
  4. Program to read .TXT file one line at a time
    By JustForLawls in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 27th, 2012, 02:02 PM
  5. Read .txt file and create objects using data
    By sevans20 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: April 14th, 2012, 01:52 PM