Getting Buffered Reader to read next line and update.

Hello.
I have been trying to get this program to read the next line in a txt file correctly. This is a GUI program
where clicking the button is supposed to bring up the next bit of information for the user to see.
I can get the first line of information to come out correctly, but I am unable to get it to read the next line when I click the next button.
Here is a snippet of my coding...
private JFileChooser fileChoose;
private File openedFile;
private int recordNumber = 0;
FileReader inFile;
String sMaker = new String (  );
else if ( ae.getActionCommand (  ) == "Next Record" )
     if ( openedFile.exists (  ) )
          nextRecord (  );
     else
     JOptionPane.showMessageDialog ( null, "No Files Opened", "No Files Found", JOptionPane.ERROR_MESSAGE );
public void nextRecord (  )
     recordNumber ++;  // Increment record number
     fileNumber.setText ( sMaker.valueOf ( recordNumber ) );  // Prints to JTextField for user to see
     BufferedReader inText;
     String lineRead;  // Holds line read in
     String [] organizedInfo;  // Array to hold info after being split
     try
          inFile = new FileReader ( openedFile );
          inText = new BufferedReader ( inFile );
          lineRead = inText.readLine (  );
          organizedInfo = ( lineRead.split ( "," ) );//.trim (  );
          for ( int i = 0; i < organizedInfo.length; i ++ )
               organizedInfo[i] = organizedInfo.trim ( );
name.setText ( organizedInfo[0] );
city.setText ( organizedInfo[1] );
state.setText ( organizedInfo[2] );
catch ( FileNotFoundException fnfe )
JOptionPane.showMessageDialog ( null, "Selected File was Not Found", "File Not Found", JOptionPane.ERROR_MESSAGE );
catch ( IOException ioe )
JOptionPane.showMessageDialog ( null, "IO Error. Please Try Again.", "IO Error", JOptionPane.ERROR_MESSAGE );
employee.txt
William Wallace,Richmond,VA
Samuel Gompers , San Francisco , California
Andy Smith,Rochester,NY
Sandy Beach,Pittsford,NY
Slim T. None,San Francisco,CA
George Jones, Washington , D.C.
Marvin Martin, Boston , Massachusetts
I. M. Last , Deadmans Gulch, Arizona
Everytime I click the next button, it should go through the list in employee.txt until i reach the end. But it just stops at William Wallace.
I know that this can be recoded to make it more efficient, but before that, I still need to figure out how to get the line read to update to next line.
Thank you in advance.

Your program works perfectly correctly!
Each time you click the button it reads the first line and displays it. Why? Because you create a new reader everytime you enter the nextRecord method and the reader reads the first line. Each new reader has no idea where the last reader was upto in your file. It has to start at the beginning.
<cue response>How do I fix it?

Similar Messages

  • Adobe reader has buttons next page and previous page, why not also top of current page and bottom of

    Adobe reader has buttons "next page" and "previous page",
    why not alson "bottom of current page" and "top of current page" ,
    these would be very useful if the page is increase to the maximum left and right

    This is a user forum; if you have any product enhancement requests, do it here: https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform

  • My ipod turned white, cant get color screen back on. tried restore and update but it says cant download to my computer. can anyone help?

    my ipod turned white on the screen. cant get normal screen back. tried to restore and update to 4.2 but it says it cant download and to check my computer settings. can anyone help?

    Go here to find out what to do with the specific error you received.
    http://support.apple.com/kb/TS3694
    What was the wording of the message?

  • I keep getting error 3004 when i try restoring and updateing my iphone 4 to iOS 7 i did everything 1. flushed dns 2. edited hosts 3. updated itunes and downloaded new one 4. switched usb ports 5. disabled antivirus 6. enabled ports 80 and 443 7. disabled

    I keep getting error 3004 when i try restoring and updateing my iphone 4 to iOS 7 i did everything 1. flushed dns 2. edited hosts 3. updated itunes and downloaded new one 4. switched usb ports 5. disabled antivirus 6. enabled ports 80 and 443 7. disabled firewall 8. even tryed putting mobile in DFU mode to restore it not of this worked so please help me

    please replyyy i'm stuck on this like whole week

  • I got an email saying my Apple account was going to be suspended unless I validated through an email.  Is this legit?  I did go on line and update my info, but I'm not convinced that was actually from Apple.

    I got an email saying my Apple account was going to be suspended unless I validated through an email.  Is this legit?  I did go on line and update my info, but I'm not convinced that was actually from Apple.

    It is a phishing attempt. Do not respond. Do not divulge any personal or financial information. You can use the address below to forward the suspect email message to Apple.
    [email protected]
    The link below has information to help identify fraudulent emails.
    http://support.apple.com/kb/HT4933

  • HT201412 My I phone five isn't responding and when I turn it on, I get a white screen with black lines and I can't get into my phone. What is happening?

    My iPhone five decided to go crazy and give me a white screen with black stripes and I can't get into my phone. I can only use Siri! What's happening?

    You posted in the iPad forum instead of the iPhone forum. To get answers to your question, next time post in the proper forum. See https://discussions.apple.com/index.jspa  I'll request that Apple relocate your post.
     Cheers, Tom

  • How to add a New schedule line and update the order quantity?

    Hi all,
       I have to add a new schedule line in VA01/VA02 so that when ther is partial confirmed quantity against a schedule line, we have to create a new schdule line based on the existing so that it will contain confirmed in one and unconfirmed in the other.
    The schedule line will split once the user go to Header data screen in VA01/VA02. So I used USEREXIT_MOVE_FIELD_TO_VBAK  user exits in MV45AFZZ include program.
        I splited the order quantity against the confirmed quantity and added it as new schedule line in the XVBEP internal table and update UPDKZ flags for XVBEP & YVBEP.
      Could anyone tell me is there any other way to do this without updating XVBEP? Because it is affecting some other place because of index table is not updating. How to you think use if update xvbap-etenr_high and update index table IVBEP1 for new line insert into XVBEP instead directly inseritng it into?
    My code as follows:
    xvbep-WMENG = t_temp-WMENG .
    modify xvbep TRANSPORTING WMENG.
    t_temp1- ETENR = '0002'.
    if SY-SUBRC <> 0.
      t_temp1-UPDKZ = UPDKZ_NEW.
      modify xvbep TRANSPORTING WMENG UPDKZ.
    endif.
    With Regards
      Raj

    Have you got thru this one if so please provide me with the solution as i got the same req' ..

  • HT4623 I keep getting error 21 when trying to restore and update my 4 day old iPhone 5?

    I try to update and restore my new iphone 5 becasue it is stuck in recovery mode but i come across error 21 message every time during restore. VERY FRUSTRATING as i only got this wonderful product 3 days ago!

    Error 20, 21, 23, 26, 28, 29, 34, 36, 37, 40
    These errors typically occur when security software interferes with the restore and update process. FollowTroubleshooting security software issues to resolve this issue. In rare cases, these errors may be a hardware issue. If the errors persist on another computer, the device may need service.
    Also, check your hosts file to verify that it's not blocking iTunes from communicating with the update server. See iTunes: Advanced iTunes Store troubleshooting—follow steps under the heading Blocked by configuration (Mac OS X / Windows) > Rebuild network information > Mac OS X > The hosts file may also be blocking the iTunes Store. If you have software used to perform unauthorized modifications to the iOS device, uninstall this software prior to editing the hosts file to prevent that software from automatically modifying the hosts file again on restart.

  • I purchased many applications prior to the Apple App Store.  How do I get the store to recognize those apps and update them?

    I purchased many application prior to the App store.  How do I get the App Store to recoginize and update those applications?

    A the moment you can not

  • Getting gnome to run from command line and over VNC

    Hi, I just got to the part of the Beginners guide, dealing with gnome and for some reason
    $ startx
    didn't give me a gnome desktop, X same with
    $ xinit
    but
    $ xinit /usr/bin/gnome-session
    worked and gave me a desktop.  From the gnome guide
    $ gnome-session
    generated the following error
    ** (gnome-session:4591): WARNING **: Cannot open display:
    Anyone know why I am getting these errors?
    VNC
    my xstartup used to look like
    #!/bin/sh
    vncconfig -iconic &
    unset SESSION_MANAGER
    unset DBUS_SESSION_BUS_ADDRESS
    OS=`uname -s`
    if [ $OS = 'Linux' ]; then
    case "$WINDOWMANAGER" in
    *gnome*)
    if [ -e /etc/SuSE-release ]; then
    PATH=$PATH:/opt/gnome/bin
    export PATH
    fi
    esac
    fi
    if [ -x /etc/X11/xinit/xinitrc ]; then
    exec /etc/X11/xinit/xinitrc
    fi
    if [ -f /etc/X11/xinit/xinitrc ]; then
    exec sh /etc/X11/xinit/xinitrc
    fi
    [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
    xsetroot -solid grey
    xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    twm &
    with exec gnome-session added in, it still gave me a x desktop. Now it looks like
    #!/bin/sh
    autocutsel -fork
    export XKL_XMODMAP_DISABLE=1
    exec gnome-session
      and works. Am I missing out on anything by omitting the old stuff? Any suggestions? Also if my inittab looks like this
    # /etc/inittab
    # Runlevels:
    # 0 Halt
    # 1(S) Single-user
    # 2 Not used
    # 3 Multi-user
    # 4 Not used
    # 5 X11
    # 6 Reboot
    ## Only one of the following two lines can be uncommented!
    # Boot to console
    id:3:initdefault:
    # Boot to X11
    #id:5:initdefault:
    rc::sysinit:/etc/rc.sysinit
    rs:S1:wait:/etc/rc.single
    rm:2345:wait:/etc/rc.multi
    rh:06:wait:/etc/rc.shutdown
    su:S:wait:/sbin/sulogin -p
    # -8 options fixes umlauts problem on login
    c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
    c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux
    c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux
    c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux
    c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux
    c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux
    # Hypervisor Virtual Console for Xen and KVM
    #h0:2345:respawn:/sbin/agetty -8 38400 hvc0 linux
    ca::ctrlaltdel:/sbin/shutdown -t3 -r now
    # Example lines for starting a login manager
    x:5:respawn:/usr/bin/xdm -nodaemon
    #x:5:respawn:/usr/sbin/gdm -nodaemon
    #x:5:respawn:/usr/bin/kdm -nodaemon
    #x:5:respawn:/usr/bin/slim >/dev/null 2>&1
    # End of file
    Do I need to worry about the login security hole?

    karol wrote:If you don't use a display manager, create one.
    Ok, but if I make any display manager do I become susceptible to this attack? Further, am I ok with my current xstartup?

  • I get a box with a grey line and a question (?) and am unable to use Firefox as if computer is locked frozen uped? Have had to load two(2) Firefox's in order to

    When I open Firefox I get a blank box in the middle of the screen with a grey bar and a (?) and the page is frozen as if the computer is frozen ~~~ I have to load two (2) Firefox pages in order to get Firefox to work? Any suggestion as to how to fix this problem?

    CS2 is very old and reached its "end of life" a while back.  So probably won't run on modern operating systems.  If you can still run it, you'll need to uninstall what you have and re-install with the download link below to activate it.
    Error: Activation Server Unavailable | CS2, Acrobat 7, Audition 3
    Nancy O.

  • How to not repeat the column values if repeated on next line and so on..?

    Hi all,
    The XmlP template that is designed gives me the output as follows :
    COL1 COL2 COL3 COL4 COL5 COL6 COL7
    abc 1 1000.00 10.00 95.00 695.00 cad
    abc 2 1000.00 100.00 95.00 695.00 cad
    abc 3 1000.00 100.00 95.00 695.00 cad
    But my requirement is as follows :
    COL1 COL2 COL3 COL4 COL5 COL6 COL7
    abc 1 1000.00 10.00 95.00 795.00 cad
    - 2 - 100.00 - - -
    - 3 - 100.00 - - -
    Note : "-" indicates blank column values (gaps are being filled)
    How do I not repeat the column values if repeated?
    Please let me know if you have answer for it?
    Thanks in Advance
    Munna

    Iam trying to design the xml publisher template using xmlp template builder.
    My requirement is :
    For a receipt number, I have receipt amount, applied amount, unapplied amount and on account amount. And for each receipt, there can be multiple applied amount ( as the receipt can be applied multiple times), but the unapplied amount, on account amount and receipt amount is single.
    By using the logic as said above from http://blogs.oracle.com/xmlpublisher/2007/04/13
    Iam getting the output something like this:
    Receipt Number| Receipt Amount | App Amount |UnappAmount|OnaccountAmount|
    111-b|249.28|249.28|0.00|0.00|
    1110|1,000.00|10.00|95.00|795.00|
    1110| -|10.00|-|-|
    1112|1500.00|1,271.02|-|-|
    1112|-|228.98|-|-|
    My requirement is to go get something like this:
    Receipt Number| Receipt Amount | App Amount |UnappAmount|OnaccountAmount|
    111-b|249.28|249.28|0.00|0.00|
    1110|1,000.00|10.00|95.00|795.00|
    1110| -|10.00|-|-|
    1112|1500.00|1,271.02|0.00|0.00| ---> here lies the difference
    1112|-|228.98|-|-|
    How do i check the duplicate of the column values only for a receipt number??
    Because as for receipt no. 111-b the unapplied amount and on account amount is 0.00, the the unapplied amount and on account amount for receipt number 1112 is getting hided( because its a duplicate) . In reality, it should be 0.00 and any other line for that receipt number (1112) should be hided. except for the applied amount.
    Note We can see that last 2 columns in the last record( for receipt number 1112) is getting hided that is as expected but for 4th record the unapplied amount and on account amount should be 0.00 respecively.
    '-' indicates hided value
    Please help.
    Thanks in Advance

  • In making a monthly budget how do you repeat for next month and update the dates to the next month?

    i want to make my budget speadsheet update the month and date as it goes to the next month automatically, from sheet to sheet.  is there any way to make this happen?

    You could have a cell where you enter the month and year...
    Or you could pull the month and year from the first entry in the date column.  Like Barry I would want more information regarding your  set up before proposing any other, more specific, ideas.

  • Im getting a code 3014 when i try and update or restore

    im getting a code 3014 when i try to upgrade to ios6 but now Phone is in restore mode and is still sending the same code 3014

    This device is not eligible for the requested build (Also sometimes displayed as an "error 3194")
    Update to the latest version of iTunes.
    Third-party security software or router security settings can also cause this issue. To resolve this, followTroubleshooting security software issues.
    Downgrading to a previous version of iOS is not supported. If you have installed software to performunauthorized modifications to your iOS device, that software may have redirected connections to the update server (gs.apple.com) within the Hosts file. Uninstall the unauthorized modification software from the computer.
    Edit out the "gs.apple.com" redirect from your hosts file, and then restart the computer for the host file changes to take affect. For steps to edit the Hosts file and allow iTunes to communicate with the update server, see iTunes: Troubleshooting iTunes Store on your computer, iPhone, iPad, or iPod—follow steps under the heading Blocked by configuration (Mac OS X / Windows) > Rebuild network information > The hosts file may also be blocking the iTunes Store. If you do not uninstall the unauthorized modification software prior to editing the hosts file, that software may automatically modify the hosts file again on restart.
    Avoid using an older or modified .ipsw file. Try moving the current .ipsw file (see Advanced Steps > Rename, move, or delete the iOS software file (.ipsw) below for file locations), or try restoring in a new user to ensure that iTunes downloads a new .ipsw.

  • Getting the following message when I try and update my .dwt "sharing violation".

    Hi all,
    I am receiving the following message whenever I try to update a .dwt for one of my sites. "A sharing violation occured while accessing C:\websitename\templates\index.dwt".  I never have gottent this before, the only thing that has changed is that I reinstalled DW on a different machine.
    Any help is greatly appreciated.

    Sorry all, I shut my machine down and restarted and the message stopped. Closing this discussion .. thank you.

Maybe you are looking for