How would you read in each line of data and display them to message box?

How would you read in each line of data from the _.txt file_ and display the whole data using an information-type message box?
I know how to display each line of the .txt file data, but I do not know how to display the whole thing.
Here is how I did to display each line of data using the message box:
import javax.swing.JOptionPane;          // Needed for the JOptionPane class
import java.io.*;                         // Needed for file classes
public class problem3
     public static void main(String[] args) throws IOException
          String filename;          // Needed to read the file
          String categories;          // Needed to read the categories
          // Get the filename.
          filename = JOptionPane.showInputDialog("Enter the filname.");
          // Open the file.
          FileReader freader = new FileReader(filename);
          BufferedReader inputFile = new BufferedReader(freader);
          // Read the categories from the file.
          categories = inputFile.readLine();
          // If a category was read, display it and
          // read the remainig categories.
          while(categories != null)
               // Display the last category read.
               JOptionPane.showMessageDialog(categories);
               // Read the next category.
               categories = inputFile.readLine();
          // Close the file.
          inputFile.close();
}I think I need to change here:
// If a category was read, display it and
          // read the remainig categories.
          while(categories != null)
               // Display the last category read.
               JOptionPane.showMessageDialog(categories);
               // Read the next category.
               categories = inputFile.readLine();
          }but I don't know how to.
Could you please help me?
Thank you.

kyorochan wrote:
jverd wrote:
What is not understood about your question is which part of "read a bunch of lines and display them in a textbox" do you not understand.
First thing's first though: You do recognize that "read a bunch of lines and display them in a textbox" has a few distinct and completely independent parts, right?I'm sorry. I'm not good at English, so I do not understand what you said...
What I was trying to say is "How to display the whole lines of .txt file in single dialog box."We know that.
Do you understand that any problem can be broken down into smaller pieces?
Do you understand that your problem has the following pieces?
1. Read lines from the file.
2. Put the lines together into one String.
3. Put the String into the message box.
and maybe
4. Make sure the message box contents are split into lines exactly as the file was.
(You didn't make it clear if that last one is a requirement.)
Do you understand that 1-4 are completely independent problems and can be solved separately from each other?
Do you understand that you have stated that you already know how to do 1 and 3?
Therefore, you are NOT asking "How to display the whole lines of .txt file in single dialog box." Rather, you ARE asking either #2 or #4 or both.
If you say once more "display all the lines of the file in one dialog box," then it is clear that we are unable to communicate with you and we cannot help you.

Similar Messages

  • How can you pull in pdf's from iBooks and bring them into the Box app?

    How can you pull in pdf's from iBooks and bring them into the Box app?

    That sounds great, but I'm lost.
    I followed these steps:
    1) Open your PDF (in Adobe Acrobat Pro)
    2) Chose print
    The print/printer options pop-up will show.
    3) In the printer section, do not use your normal printer, a printer named Adobe PDF should be an option. Chose it.
    4) Under the "Page handling" section, change the Page Scaling drop-down menu to "Multiple pages per sheet".
    It works fine, but it looses all of the font information and the search no longer works. How can you do it and save the font info, so the search tool continues to operate.
    Am I missing anything?

  • How would you edit 4k in Premiere Pro CC and export in 2.5k and 1080p (all within premiere pro, is it possible?), how would you edit 4k in Premiere Pro CC and export in 2.5k and 1080p (all within premiere pro, is it possible?)

    how would you edit 4k in Premiere Pro CC and export in 2.5k and 1080p (all within premiere pro, is it possible?), how would you edit 4k in Premiere Pro CC and export in 2.5k and 1080p (all within premiere pro, is it possible?)

    Edit 4K and export what ever you want from AME

  • In Pages 5.2.2: How do you go from 1 column to 2 and keep them on the same page?

    In Pages 5.2.2: How do you go from 1 column to 2 and keep them on the same page?

    Sorry, I tried to say your answer solved my question, but I guess I told it that my response to you solved it. Now that I liked it, the solved option doesn't appear.

  • Read numbers from a .txt file and display them in a graph

    How can I get Labview 7 to read from a txt. file containing a lot of
    coloumns with different datas? There`s only two of the coloumns that are
    interesting to me, the first, that contains the time of the measuring, and
    one in the middle, that contains the measured temperatures. I want Labview
    to read this datas and display them graphicly.
    Thanks from Stale

    Here's one way.
    You can also use the help-> find examples and search for "text".
    2006 Ultimate LabVIEW G-eek.
    Attachments:
    Graph.vi ‏21 KB

  • How do you read in different kinds of data?

    Hi
    How do you read in integers first and next read in a string of characters?
    Please help.
    Thanks,
    Sincerely,
    Egan

    You don't give enough information to provide a definitive reply. DataInputStream is Java's IO class that is designed to do that . This reference has example code of how it's used.
    http://java.sun.com/docs/books/tutorial/essential/io/dataIO.html

  • How to Read the one Source Column data and Display the Results

    Hi All,
         I have one PR_ProjectType Column in my Mastertable,Based on that Column we need to reed the column data and Display the Results
    Ex:
    Pr_ProjectType
    AD,AM
    AD
    AM
    AD,AM,TS,CS.OT,TS
    AD,AM          
    like that data will come now we need 1. Ad,AM then same we need 2. AD also same we need 3. AM also we need
    4.AD,AM,TS,CS.OT,TS in this string we need AD,AM  only.
    this logic we need we have thousand of data in the table.Please help this is urgent issue
    vasu

    Hi Vasu,
    Based on your description, you want to eliminate the substrings (eliminated by comma) that are not AD or AM in each value of the column. Personally, I don’t think this can be done by just using an expression in the Derived Column. To achieve your goal, here
    are two approaches for your reference:
    Method 1: On the query level. Replace the target substrings with different integer characters, and create a function to eliminate non-numeric characters, then replace the integer characters with the corresponding substrings. The statements
    for the custom function is as follows:
    CREATE FUNCTION dbo.udf_GetNumeric
    (@strAlphaNumeric VARCHAR(256))
    RETURNS VARCHAR(256)
    AS
    BEGIN
    DECLARE @intAlpha INT
    SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric)
    BEGIN
    WHILE @intAlpha > 0
    BEGIN
    SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, '' )
    SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric )
    END
    END
    RETURN ISNULL(@strAlphaNumeric,0)
    END
    GO
    The SQL commands used in the OLE DB Source is like:
    SELECT
    ID, REPLACE(REPLACE(REPLACE(REPLACE(dbo.udf_GetNumeric(REPLACE(REPLACE(REPLACE(REPLACE([ProjectType],'AD,',1),'AM,',2),'AD',3),'AM',4)),4,'AM'),3,'AD'),2,'AM,'),1,'AD,')
    FROM MyTable
    Method 2: Using a Script Component. Add a Derived Column Transform to replace the target substrings as method 1, use Regex in script to remove all non-numeric characters from the string, add another Derived Column to replace the integer
    characters to the corresponding substring. The script is as follows:
    using System.Text.RegularExpressions;
    Row.OutProjectType= Regex.Replace(Row.ProjectType, "[^.0-9]", "");
    References:
    http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/ 
    http://labs.kaliko.com/2009/09/c-remove-all-non-numeric-characters.html 
    Regards,
    Mike Yin
    TechNet Community Support

  • How Would You Handle Carridge Returns & Line Feeds in A Spreadsheet file.

    I have susessfully created a logging program which creates a spreadsheet file. I have additional information added after the loggging data is complete which I have seperated it by a CR/LF. How can I display this particular part of the file only?
    I have attached the file in question, "DATA15.dat".
    Attachments:
    DATA15.dat ‏1 KB

    Read the file like you normally do (2 D array (from Spread sheet file) )
    Then scan the first column for the CR/LF character and find the index of it (may want to use serach 1D array for the collumn).
    Then Divide the array into 2 diffrenet arrays, 1 above the found index (containg data to display), and the other one to ignore, or simply use "array subset" function

  • How would you select part of a letter/font and change the colour of it ??

    for example i want to selct the the letter 'b' and just want to change the colour of the ascender' ( the top half of the b) how could i do this on INDESIGN
    like this

    Here are a few tips to get started:
    (1) When you create outlines, hold down the Option/Alt key when you choose Type > Create Outlines. That will make a copy of the outlines which isn't anchored in the text frame. Move that copy away from the original frame.
    (2) Select all the word with the Direct Selection tool and choose Object > Path > Release Compound Path. That will separate the letters from each other so you can work with them (it also fills in the counters (centers) of the letters).
    (3) To create the effect on the "T," I selected the letter with the Direct Selection tool (selecting all the anchor points) and chose File > Copy, then chose Edit > Paste in Place to make a copy on top.
    (4) I moved the top copy a little (Shift + Up Arrow) so I could select the bottom copy, then I locked the bottom copy (Object > Lock). I moved the top copy back (Shift + Down Arrow).
    (5) With the Direct Selection tool, I selected the lower anchor points and deleted them. I filled the top anchor points with blue. Here is how far I got:

  • How do you copy the templates from another webstie and use them as your own?

    Hi Everyone, I was told that with Dreamweaver it is possible to copy another websites templates? What are the steps in copying another websites template with Dreamweaver? I would like to know I am a newbie when it comes to this program so please make your statement understandable for me, thanks. Also, I am having problems creating a drop down menu for each of my web pages. When I go to highlight a specific box on my homepage I want the dropdown menu to appear vertically and not horizontally. I may have missed something when watching the video tutorials or I didn't quite understand what they meant. Thank you for any information on the series of questions that I have asked in this new thread.

    Hi Everyone, I was told that with Dreamweaver it is possible to copy another websites templates? What are the steps in copying another websites template with Dreamweaver?
    This is difficult to understand.   How are you copying templates from another site?
    If you have all the files that make up the template, then it's only a matter of saving all the files to a folder on your hard drive and setting up a site definition pointing to this folder.  You then work on the files as usual.
    Also, I am having problems creating a drop down menu for each of my web pages. When I go to highlight a specific box on my homepage I want the dropdown menu to appear vertically and not horizontally. I may have missed something when watching the video tutorials or I didn't quite understand what they meant. Thank you for any information on the series of questions that I have asked in this new thread.
    Without seeing the page it's difficult to judge what your problem is.  If possible, please upload the files to a remote server and provide a link to the page. It's the only way people can help - if they see your page in action.
    Nadia
    Adobe® Community Expert : Dreamweaver
    Unique CSS Templates | Tutorials | SEO Articles
    http://www.DreamweaverResources.com
    Web Design & Development
    http://www.perrelink.com.au
    http://twitter.com/nadiap

  • How use PHP to read image files from a folder and display them in Flex 3 tilelist.

    Hello. I need help on displaying images from a folder dynamically using PHP and display it on FLEX 3 TileList. Im currently able to read the image files from the folder but i don't know how to display them in the TileList. This is my current code
    PHP :
    PHP Code:
    <?php
    //Open images directory
    $imglist = '';
    $dir = dir("C:\Documents and Settings\april09mpsip\My Documents\Flex Builder 3\PHPTEST\src\Assets\images");
    //List files in images directory
    while (($file = $dir->read()) !== false)
    if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
    echo "filename: " . $file . "\n";
    $dir->close();
    ?>
    FLEX 3 :
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="pic.send();">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.rpc.events.FaultEvent;
    import mx.events.ItemClickEvent;
    import mx.rpc.events.ResultEvent;
    public var image:Object;
    private function resultHandler(event:ResultEvent):void
    image = (event.result);
    ta1.text = String(event.result);
    private function faultHandler(event:FaultEvent):void
    ta1.text = "Fault Response from HTTPService call:\n ";
    ]]>
    </mx:Script>
    <mx:TileList x="31" y="22" initialize="init();" dataProvider = "{image}" width="630" height="149"/>
    <mx:String id="phpPicture">http://localhost/php/Picture.php</mx:String>
    <mx:HTTPService id="pic" url="{phpPicture}" method="POST"
    result="{resultHandler(event)}" fault="{faultHandler(event)}"/>
    <mx:TextArea x="136" y="325" width="182" height="221" id="ta1" editable="false"/>
    <mx:Label x="136" y="297" text="List of files in the folder" width="182" height="20" fontWeight="bold" fontSize="13"/>
    </mx:Application>
    Thanks. Need help as soon as possbile. URGENT.

    i have made some changes, in the php part too, and following is the resulting code( i tried it, and found that it works.):
    PHP Code:
    <?php
    echo '<?xml version="1.0" encoding="utf-8"?>';
    ?>
    <root>
    <images>
    <?php
    //Open images directory
    $dir = dir("images");
    //List files in images directory
    while (($file = $dir->read()) !== false)
    if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
    echo "<image>" . $file . "</image>"; // i expect you to use the relative path in $dir, not C:\..........
    //$dir->close();
    ?>
    </images>
    </root>
    Flex Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute"
    creationComplete="callPHP();">
    <mx:Script>
    <![CDATA[
    import mx.rpc.http.HTTPService;
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.rpc.events.FaultEvent;
    import mx.events.ItemClickEvent;
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;
    [Bindable]
    private var arr:ArrayCollection = new ArrayCollection();
    private function callPHP():void
    var hs:HTTPService = new HTTPService();
    hs.url = 'Picture.php';
    hs.addEventListener( ResultEvent.RESULT, resultHandler );
    hs.addEventListener( FaultEvent.FAULT, faultHandler )
    hs.send();
    private function resultHandler( event:ResultEvent ):void
    arr = event.result.root.images.image as ArrayCollection;
    private function faultHandler( event:FaultEvent ):void
    Alert.show( "Fault Response from HTTPService call:\n " );
    ]]>
    </mx:Script>
    <mx:TileList id="tilelist"
    dataProvider="{arr}">
    <mx:itemRenderer>
    <mx:Component>
    <mx:Image source="images/{data}" />
    </mx:Component>
    </mx:itemRenderer>
    </mx:TileList>
    </mx:Application>

  • How do you Take songs from one iTunes library and put them on another(Mac)

    Well i have some songs that i don't really listen to anymore so i don't want them on my library or any of my ipods but i don't want to delete them because i bought them so i want to put them on another itunes library i created but i cant figure out how to take them out of my library and put them on the other one
    how do you do that?

    Open your other library, go to File>Add to library and navigate to the folder containing the files you want to add. Once they are in your new library delete them from the other library making sure that when you get the prompt to move them to trash say no. You should also back your purchases up to disc or to an external drive so you don't lose them of anything happens to your hard drive:
    How to back up your media in iTunes
    Back up your iTunes library by copying to an external hard drive

  • I have read 118 files (from a directory) each with 2088 data and put them into a 2 D array with 2cols and 246384row, I want to have aeach file on a separate columns with 2088 rows

    I have read 118 files from a directory using the list.vi. Each file has 2 cols with 2088rows. Now I have the data in a 2 D array with 2cols and 246384rows (118files * 2088rows). However I want to put each file in the same array but each file in separate columns. then I would have 236 columns (2cols for each of the 118 files) by 2088 rows. thank you very much in advance.

    Hiya,
    here's a couple of .vi's that might help out. I've taken a minimum manipulation approach by using replace array subset, and I'm not bothering to strip out the 1D array before inserting it. Instead I flip the array of filenames, and from this fill in the end 2-D array from the right, overwriting the column that will eventually become the "X" data values (same for each file) and appear on the right.
    The second .vi is a sub.vi I posted elsewhere on the discussion group to get the number of lines in a file. If you're sure that you know the number of data points is always going to be 2088, then replace this sub vi with a constant to speed up the program. (by about 2 seconds!)
    I've also updated the .vi to work as a sub.vi if you wa
    nt it to, complete with error handling.
    Hope this helps.
    S.
    // it takes almost no time to rate an answer
    Attachments:
    read_files_updated.vi ‏81 KB
    Num_Lines_in_File.vi ‏62 KB

  • How to Allow Reader Users to Save XML Data and Send?

    A huge problem w/ LiveCycle Designer is (this is what I found), by clicking the "Submit via Email" button, the Adobe Reader is trying to connect to the local default email program, like outlook express.
    However, public computers are usually banned the users to launch an email program, and users are more likely to check email within a webpage. I noticed a number of students close the Reader after filling out the form but failing to send back the data.
    Anyway that I can allow a Reader user to be able to save .xml data file so he/she can attach to web-based email?
    Thanks Everybody!

    If you have Acrobat there is a subset of Reader Extensions functionality available in there that will allow you to Reader Extend the form to do local saves. The license agreement limits you to 500 uses. If you need more than that there is a server option that is more expensive but has no limits on users.

  • In Security, clicking on the "Saved Password" button displays your current saved password for each site. It does not allow you to change a password. How would you do that?

    In Security, clicking on the "Saved Password" button displays your current saved password for each site. It only allows you to view and delete site passwords. It does not allow you to change a password. How would you do that?

    If you enter a new password Firefox should offer to change the password.
    *You may not need to delete the old password. Try "Refreshing" the page, entering the site again, you may need to let Firefox fill in the old password, then enter the new password, and Firefox should ask to save the new password. See:
    **http://kb.mozillazine.org/Deleting_autocomplete_entries
    *If you delete the old password, you may need to "Refresh" the site after deleting the old password.
    If you want to delete the password that has been saved do the following:
    #In the Tools menu select Options to open the options window
    #Go to the Security panel
    #Click the "Saved Passwords" button to open the passwords manager
    #Select the site in the list, then click Remove
    <br />
    <br />
    '''You need to update the following.''' The Plugin version(s) shown below was/were submitted with your question and is/are out of date. You should update to avoid known security issues with the version(s) you have installed. Click on "More system info..." to the right of your question to see what was included with your question.
    *Adobe PDF Plug-In For Firefox and Netscape 8.3.0 (''Note: this is a very old version and installing the current version may not delete it or overwrite it. To avoid possible problems with having 2 versions installed on your system, you may want to remove the old version in Windows Control Panel > Add or Remove Programs before installing the new version'').
    *Shockwave Flash 10.3 r181 (''this may be current but a new version was released on 2011-06-14 with a ".26" after the "181". You can use the Plugin Check below and/or look in Add-ons > Plugins for the version of Shockwave Flash that you have installed. The newest version will be shown in Add-ons > Plugins as "Shockwave Flash 10.3.181.26"'').
    *Next Generation Java Plug-in 1.6.0_24 for Mozilla browsers
    #'''''Check your plugin versions''''' on either of the following links':
    #*http://www.mozilla.com/en-US/plugincheck/
    #*https://www-trunk.stage.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #*There are plugin specific testing links available from this page:
    #**http://kb.mozillazine.org/Testing_plugins
    #'''Update Adobe Reader (PDF plugin):'''
    #*From within your existing Adobe Reader ('''<u>if you have it already installed</u>'''):
    #**Open the Adobe Reader program from your Programs list
    #**Click Help > Check for Updates
    #**Follow the prompts for updating
    #**If this method works for you, skip the "Download complete installer" section below and proceed to "After the installation" below
    #*Download complete installer ('''if you do <u>NOT</u> have Adobe Reader installed'''):
    #**SAVE the installer to your hard drive (save to your Desktop so that you can find it after the download). Exit/Close Firefox. Run the installer you just downloaded.
    #**Use either of the links below:
    #***https://support.mozilla.com/en-US/kb/Using+the+Adobe+Reader+plugin+with+Firefox ''(click on "Installing and updating Adobe Reader")''
    #***''<u>Also see Download link</u>''': http://get.adobe.com/reader/otherversions/
    #*After the installation, start Firefox and check your version again.
    #'''Update the [[Managing the Flash plugin|Flash]] plugin''' to the latest version.
    #*Download and SAVE to your Desktop so you can find the installer later
    #*If you do not have the current version, click on the "Player Download Center" link on the "'''Download and information'''" or "'''Download Manual installers'''" below
    #*After download is complete, exit Firefox
    #*Click on the installer you just downloaded and install
    #**Windows 7 and Vista: may need to right-click the installer and choose "Run as Administrator"
    #*Start Firefox and check your version again or test the installation by going back to the download link below
    #*'''Download and information''': http://www.adobe.com/software/flash/about/
    #**Use Firefox to go to the above site to update the Firefox plugin (will also install plugin for most other browsers; except IE)
    #**Use IE to go to the above site to update the IE ActiveX
    #*'''Download Manual installers'''.
    #**http://kb2.adobe.com/cps/191/tn_19166.html#main_ManualInstaller
    #**Note separate links for:
    #***Plugin for Firefox and most other browsers
    #***ActiveX for IE
    #'''Update the [[Java]] plugin''' to the latest version.
    #*Download site: http://www.oracle.com/technetwork/java/javase/downloads/index.html (Java Platform: Download JRE)
    #**'''''Be sure to <u>un-check the Yahoo Toolbar</u> option during the install if you do not want it installed.
    #*Also see "Manual Update" in this article to update from the Java Control Panel in Windows Control Panel: http://support.mozilla.com/en-US/kb/Using+the+Java+plugin+with+Firefox#Updates
    #* Removing old versions (if needed): http://www.java.com/en/download/faq/remove_olderversions.xml
    #* Remove multiple Java Console extensions (if needed): http://kb.mozillazine.org/Firefox_:_FAQs_:_Install_Java#Multiple_Java_Console_extensions
    #*Java Test: http://www.java.com/en/download/help/testvm.xml

Maybe you are looking for

  • Error while applying patch 6728000

    Hi all, I am applying the patch 6728000 and I now get an error, this is in the log: Connecting to APPS ... Connected successfully. Calling FNDLOAD function. Returned fro FNDLOAD function. Log file: Error calling FNDLOAD function What should I do to f

  • The old black screen thing

    hi I was working on my laptop, closed it, then opened it again only to get a black or blank screen. Rebooted but can't get any hard drive noise (i think - could just be very quiet). Keyboard kinda works but not in the way i set it up. So theres some

  • Smartform error

    Hi, I have just moved my smart form from Sandbox to development. I downloaded the form from sandbox to my local machine and then uploaded the form from local machine to development environment. The smartform was working fine in sandbox (in web), but

  • Client Export -- Parellel Processing....

    When I went to SCC8 (Client Export), I saw an option called parellel processing (Any way it was disabled). May I know whether there is a chance for enabling parellel processing in Client Export?

  • 150:30 error. How can I have  Access to programs again?

    hard drive died.New hard drive in.  Now I cant access adobe Illusttrator/Photoshop anymore. 150:30 error message. Also don't have access to my adobe creative suite hard copies anymore, got lost in the move. Need to have my Adobe programs working. How