Finding the end of a document using Scanner

I'm reading a file line by line, but cannot figure out how to read the end of a document without finding the number of lines in the document myself. When I have all of the lines printed out, I get an error at the end saying that no line could be found, which makes sense, since it's the end of the document. But how can I detect the end without getting an error?
Exception in thread "main" java.util.NoSuchElementException: No line found
     at java.util.Scanner.nextLine(Unknown Source)
     at GustavData.main(GustavData.java:29)

Note: This thread was originally posted in the [Java Programming|http://forums.sun.com/forum.jspa?forumID=31] forum, but moved to this forum for closer topic alignment.

Similar Messages

  • How do I use Spotlight to find the location of a document?

    Spotlight used to show the location of document when I hovered the mouse over an item in its list. It no longer does this. Now it tells me that a document exists and allows me to open the document, but doesn't tell me where to find the document. How do I use Spotlight to find the location of a document?

    Hi Thomas ...
    Open System Preferences > Spotlight then select the Search Results tab.
    Select the all the categories for the search results you want.
    Restart your Mac.
    If that didn't help the Spotlight preferences may be corrupted.
    Go to ~/LIbrary/Preferences
    Move the com.apple.spotlight.plist file from the Preferences folder to the Trash.
    Try Spotlight.
    edited by:  cs

  • Finding the end of a file.

    How do I find the end of a stream (in this case, a file) using BufferedReader.readLine()?

    <code>
    public class SectorParser1 {
        // Declare variables that will be used
        Scanner sectorScannerIn;        // This is used in the setFileLocation method
        String sectorLocation;          // This is the abs location of the sector
        String currentIn;
        BufferedReader myParser;        // This is the top-level parser that reads
                                        // through the sct file.
        Scanner mySectorScanner;        // This is the second-level parser that
                                        // reads through the sct file.
        BufferedReader myReader;
        // Define constructors for SectorParser1
        public SectorParser1() {
        }   // CLOSE THE SectorParser1() CONSTRUCTOR
        SectorParser1(String sectorLocation) {
            this.sectorLocation = sectorLocation;
        }   // CLOSE THE SectorParser1(String sectorLocation) CONSTRUCTOR
        // Define methods for SectorParser1
        public void setFileLocation() {
            System.out.print("Please enter the exact path to your sector file: ");
            sectorScannerIn = new Scanner(System.in);
            sectorLocation = sectorScannerIn.next();
        }   // CLOSE THE setFileLocation() METHOD
        public String getFileLocation() {
            return sectorLocation;
        }   // CLOSE THE getFileLocation() METHOD
        public int beginParsing() throws IOException {
            myReader = new BufferedReader(new FileReader(sectorLocation));
            boolean cond = true;
            int counter = 0;
            try{ while(cond) {
                currentIn = myReader.readLine();
                if(currentIn.equals("null")){
                    break;
                }else if(currentIn.startsWith(";")) { // Lines in the file that's
                    continue;                         // being read that start with
                } {                                   // a ';' are comments, and
                    counter++;                        // need to be ignored.
                System.out.println(currentIn);
            } } catch (NullPointerException e) {
                System.err.println("Caught NullPointerException.");
            myReader.close();
            return counter;
    }       // CLOSE THE SectorParsing1 CLASS </code>

  • From which tables i would find the delivery and billing document field..??

    I need to create an ALV report which displays the following details in the output.
    Order No  Item No     Material     Order Qty     Item Category     Plant     Delivery     Billing Document     Sales Org     Dist Channel     Division     Created By     Created On      Changed On
    For(Order No  Item No     Material     Order Qty     Item Category     Plant) i took the fields from vbap and
    for(Sales Org     Dist Channel     Division     Created By     Created On      Changed On)i took the fields from vbak..
    From which tables i would find the delivery and billing document field related to sales document.??
    need help...
    Moderator message : Requirements dumping not allowed, thread locked.
    Edited by: Vinod Kumar on Mar 6, 2012 2:53 PM

    i am new to abap...so i dont have idea about sd table relationship.
    so please reply how to add delivery and billing doc in my coding below..
    *& Report  ZINAA_SD
    REPORT  zinaa_sd.
    TABLES: vbap, vbak, vbfa.
    TYPE-POOLS: slis.
    CONSTANTS: c_x TYPE char1 VALUE 'X'.
    TYPES:
            BEGIN OF st_vbap,
             vbeln TYPE vbap-vbeln,
             posnr TYPE vbap-posnr,
             matnr TYPE vbap-matnr,
             pstyv TYPE vbap-pstyv,
             kwmeng TYPE vbap-kwmeng,
             werks TYPE vbap-werks,
            END OF st_vbap,
            BEGIN OF st_vbak,
              vbeln TYPE vbak-vbeln,
              erdat TYPE vbak-erdat,
              ernam TYPE vbak-ernam,
              vkorg TYPE vbak-vkorg,
              vtweg TYPE vbak-vtweg,
              spart TYPE vbak-spart,
              aedat TYPE vbak-aedat,
            END OF st_vbak, 
           BEGIN OF st_final,
             vbeln TYPE vbap-vbeln,
             posnr TYPE vbap-posnr,
             matnr TYPE vbap-matnr,
             pstyv TYPE vbap-pstyv,
             kwmeng TYPE vbap-kwmeng,
             werks TYPE vbap-werks,
             erdat TYPE vbak-erdat,
             ernam TYPE vbak-ernam,
             vkorg TYPE vbak-vkorg,
             vtweg TYPE vbak-vtweg,
             spart TYPE vbak-spart,
             aedat TYPE vbak-aedat,
           END OF st_final.
    DATA:
          lt_vbap TYPE TABLE OF st_vbap,
          ls_vbap TYPE st_vbap,
          lt_vbak TYPE TABLE OF st_vbak,
          ls_vbak TYPE st_vbak,
          lt_final TYPE TABLE OF st_final,
          ls_final TYPE st_final,
          lt_fieldcat TYPE slis_t_fieldcat_alv,
          ls_fieldcat TYPE slis_fieldcat_alv,
          layout TYPE slis_layout_alv,
          lt_sort TYPE slis_t_sortinfo_alv,
          ls_sort TYPE slis_sortinfo_alv.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_vbeln FOR vbap-vbeln,
                    s_erdat FOR vbap-erdat.
    SELECTION-SCREEN END OF BLOCK b1.
    PERFORM select_data.
    PERFORM loop_final.
    PERFORM sort.
    PERFORM a USING:
          'VBELN' TEXT-002,
          'POSNR' TEXT-003,
          'MATNR' TEXT-004,
          'KWMENG' TEXT-005,
          'PSTYV' TEXT-006,
          'WERKS' TEXT-007,
          'VKORG' TEXT-008,
          'VTWEG' TEXT-009,
          'SPART' TEXT-010,
          'ERNAM' TEXT-011,
          'ERDAT' TEXT-012,
          'AEDAT' TEXT-013.
    PERFORM display.
    *&      Form  SELECT_DATA
          text
    FORM select_data.
      SELECT
       vbeln
       vkorg
       vtweg
       spart
       ernam
       erdat
       aedat
       INTO CORRESPONDING FIELDS OF TABLE lt_vbak
       FROM vbak
       WHERE vbeln IN s_vbeln AND erdat IN s_erdat.
      IF sy-subrc = 0.
        SORT lt_vbak by vbeln.
      ENDIF.
      SELECT
       vbeln
       posnr
       matnr
       kwmeng
       pstyv
       werks
       INTO CORRESPONDING FIELDS OF TABLE lt_vbap
       FROM vbap
       FOR ALL ENTRIES IN lt_vbak
       WHERE vbeln = lt_vbak-vbeln.
      IF sy-subrc = 0.
        SORT lt_vbap by vbeln.
      ENDIF.
    ENDFORM.                    "SELECT_DATA
    *&      Form  LOOP_FINAL
          text
    FORM loop_final.
      LOOP AT lt_vbap INTO ls_vbap.
        ls_final-vbeln = ls_vbap-vbeln.
        ls_final-posnr = ls_vbap-posnr.
        ls_final-matnr = ls_vbap-matnr.
        ls_final-kwmeng = ls_vbap-kwmeng.
        ls_final-pstyv = ls_vbap-pstyv.
        ls_final-werks = ls_vbap-werks.
        READ TABLE lt_vbak INTO ls_vbak WITH KEY vbeln = ls_vbap-vbeln BINARY SEARCH.
        ls_final-vkorg = ls_vbak-vkorg.
        ls_final-vtweg = ls_vbak-vtweg.
        ls_final-spart = ls_vbak-spart.
        ls_final-ernam = ls_vbak-ernam.
        ls_final-erdat = ls_vbak-erdat.
        ls_final-aedat = ls_vbak-aedat.
        APPEND ls_final TO lt_final.
        CLEAR ls_final.
      ENDLOOP.
      ENDFORM.                    "LOOP_FINAL
    *&      Form  SORT
          text
    FORM sort.
      ls_sort-spos = '01' .
      ls_sort-fieldname = 'VBELN'.
      ls_sort-tabname = 'LT_FINAL'.
      ls_sort-up = c_x.
      ls_sort-subtot = c_x.
      APPEND ls_sort TO lt_sort .
    ENDFORM.                    "SORT
    *&      Form  A
          text
         -->FNAME      text
         -->SELTEXT    text
         -->EMPHA      text
    FORM a USING fname TYPE string seltext TYPE string.
      IF fname = 'KWMENG'.
        ls_fieldcat-do_sum =  c_x.
      ENDIF.
      ls_fieldcat-fieldname = fname.
      ls_fieldcat-seltext_m = seltext.
      APPEND ls_fieldcat TO lt_fieldcat.
      CLEAR ls_fieldcat.
    ENDFORM.                    "A
    *&      Form  ALV
          text
    FORM display.
      layout-zebra = c_x.
      layout-colwidth_optimize = c_x.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = sy-repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
        is_layout                         = layout
        it_fieldcat                       = lt_fieldcat
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
        it_sort                           = lt_sort
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = C_X
      I_SAVE                            = ' '
      IS_VARIANT                        =
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
        t_outtab                          = lt_final
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "ALV

  • How do you get word count to print at the end of a document in Pages?

    How do you get word count to print at the end of a document in Pages?

    Pages v5 does not provide a user assignable word count variable. With some AppleScript, and a paste operation from the clipboard, you can have locale punctuated word count in this format: 7,803 — anywhere in your document. The following AppleScript works with Pages '09 v4.3 through Pages v5.5.2 on Yosemite.
    I would suggest that you copy paste the following AppleScript into your [Apple] Script Editor and save it (suggestion) wordcnt.applescript. Then, follow this with an option+Save As… and this time set the File format to Script Bundle, or Application with hidden extension — saved to your Desktop. Provided you have a Pages document open, you are then a double-click from the ability to paste your current word count into Pages.
    Note: If you have Pages word count display enabled, it will automatically count your pasted value as another word which initially may deceive on true word count at the time the script was run.
    AppleScript
    --- copy below this line ---
    property locale : "en_US.UTF-8" -- In Terminal, use the locale command to see yours
    if not ApplicationIsRunning("Pages") then
         display dialog "Pages must be running to use this utility."
         return quit
    end if
    tell application "Pages"
        tell body text of front document
            set wordCnt to count words
            -- Don't want punctuated numbers? Remove the single quote from printf format
            set the clipboard to (do shell script "export LC_ALL=" & locale & "; printf \"%'d\" " & wordCnt)
        end tell
    end tell
    on ApplicationIsRunning(appName)
         tell application "System Events" to set appNameIsRunning to exists (processes where name is appName)
         return appNameIsRunning
    end ApplicationIsRunning

  • How do i get my team to all see the same say, ID, document using the cloud?

    how do i get my team to all see the same say, ID, document using the cloud?

    Adobe Max was a smoke and mirror show and they demonstrated "Folder Sharing" so we bought into it. Myself and 7 of my clients. After the Max show they turned it off like nobody would notice. Two weeks after they stopped the folder sharing feature they put a little notice that they had did this. Nice how they treat their loyal customers. Every month they charged us an extra $20 over a single account without the folder sharing. What good is "team work" if you can't share a folder of files. Sharing a single file at a time is a waste of time.
    After a year still no folder sharing but the same old story of "soon". Adobe is using the extra money they are "stealing" from paying clients to pay for this development. We are being forced to pay the extra money again for another year as there is no way to downgrade to a single user account. Adobe likes to use this as an excuse to continue to rob and steal from loyal user that have no choice but to deal with these crooks.
    My only suggestion is for new users not to buy the team account package. There marketing material is filled with misleading statements that gives the potential new customer the impression that they can work in teams, as if a team can  work sharing single files. This is a sign that Adobe is about the cash grab and not about the quality of software and the end user experience.

  • How do find the end user agreement

    how do I find the end user license agreement, I'm so frustrated

    I'm guessing that you have been unable to find the way to accept the end user license for Reader. If you are in Windows (which we don't know), you can try using Windows Explorer to navigate to C:\Program Files (x86)\Adobe\Reader 11.0\Reader, then double-click on Eula.exe and accept the license agreement. If you are in Mac, open your Applications folder, double click on the Reader icon, follow the instructions to accept the license, close and restart Reader.

  • How do I find the URL for a document loaded into Buzzword?

    How do I find the URL for a document loaded into Buzzword?

    What kind of document? What is Buzzword?

  • I cant find the end button when i receive a incomming call please help me. Is there any solution for it or is it a bug in the ios7.0.3 iam updated with ios7.0.3

    I cant find the end button when i receive a incomming call please help me. Is there any solution for it or is it a bug in the ios7.0.3 iam updated with ios7.0.3

    Do you mean decline button before picking up the call?

  • Portege 2010 - Cannot find the END button in order to save BIOS changes

    I couldnt save my Bios setup because i can't find the end keys to save the changes.
    I tried to hit all the keys in keyboard but none of it save the settings.
    Can you show me the keyboard diagram showing the end keys?
    I have toshiba portege 2001 series.

    >Can you show me the keyboard diagram showing the end keys?
    I checked the user manual which you can download from the Toshiba user manual page and the END button seems to be located in the upper right corner its above the Backspace button.
    Cheers

  • I am finding  the No. of threads in use through the RWB

    Hi,
    WE have 2 server nodes,we want to compare the load distribution.
    I am finding  the No. of threads in use through the RWB -> Component Monitoring -> engine status -> Queues ... to find thread count (in use).
    I could see the thread count as 0.I even want to monitor Queues AFWCall.......
    when i press on AFWCall It shows null pointer exception.
    Pl help.
    Srini

    Hi Srinivas,
    I expect the error could be queue configuration on J2EE stack.
    That is set the Thread count corresponding to AFW queue, by increasing the thread count sufficiently we can observe the status of queue to be true.
    use the following url to find the status of the queue:
    https://<hostname>:<J2EE port>/MessagingSystem/monitor/systemStatus.jsp
    I think your problem gets resolved.
    Regards,
    Suraj Kumar

  • When I export to a .docx file it is adding an extra blank page on to the end of my document

    I completed a document in Pages.  I then chose export to>Word and exported my file as a .docx file.  When I open my newly created word document there is an extra blank page at the end of my document.  I have tried to delete it and export again but the same thing happens.  I have also tried to open a new document, cut and paste everything in and export again.  When I did this it did not add the extra page but instead changed all of my formatting.  Please Help!

    See:  https://discussions.apple.com/message/2438917#2438917  for solution

  • Where can I find the Tables script that are used in the Documentation

    Hello All,
    Where can I find the Tables script that are used in the Documentation, Like Sales, Customers, employee, department.......
    Appreciate any Help
    Thanks & Regards
    Madhu K

    10g
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14198/scripts.htm#sthref77
    9i
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96539/scripts.htm#4216

  • Where is my credit balance? I was gifted $50 for Christmas and used it but cannot find the balance and how to use it.

    I was gifted $50 for Christmas and used it ti buy a couple of albums but now canot find the balance and how to use it.

    My account's balance shows at the top left of the store's page on my computer's iTunes, and by logging in to view my account via the Store > View Account menu option. On my devices it shows at the bottom of, for example, the Featured tab in the App Store app under my account id (or you can view your account via Settings > iTunes & App Store and it should show on the screen that you are taken to).
    If nothing shows then have you checked your account's purchase history ? If you log into your account on your computer's iTunes via the Store > View Account menu option, you should then see a Purchase History section with a 'see all' link to the right of it. Click on that and you should then see a list of your purchases.
    If you have a balance then you just need to click on item's price to buy it, assuming that your balance covers its price.

  • Where can I find the end users license agreement?

    Hi!
    Every time I try to open a document online the windows pops up with the notice that I need to agree to the end user license agreement in order for me to be able to view pdf. How can i do it?

    Have you actually opened Adobe Reader (as instructed) to see if it offers the ability to accept the agreement?
    If so and it didn't work, what version of Reader, OS and web browser are you using?

Maybe you are looking for

  • PSE 10 from Apple Store problem with camera raw 6.7 upgrade

    PSE 9 was not opening Nikon d4 raw files so I've purchased PSE 10 at the Apple Store and installed on my Mac. PSE 10 is still not opening d4 raw files (camera raw 6.5). I tried to update to 6.7 taken from Adobe but did not succeed to install it. Coul

  • Saving .ai file outside of the artboard?

    Is there a way to save the whole canvas out to a .pdf and not getting content cut off at the artboards? Or do I have to specifically change the size on each artboard? I have about 400 files that the content exceededs the artboard and I need to print

  • Lifecycle Picklist values not showing up

    Hello, We are on CRM 7.0. Lifecycle stages ( BP Role Exclusion group values ) are not being displayed in the picklist. Method : GETV_PARTNERROLE in BP_HEAD/Lifecycle view_ IF ls_attributes-partnerrole IS INITIAL.     TRY.         lr_cuco ?= owner->ge

  • I need to run Illustrator in Rosetta Mode and the option isn't in Get Info

    Hello everyone, I need help. I need to run Illustrator in Rosetta Mode and the option isn't in Get Info. I'm using CS3 on a Mac Book Pro 2.16GHz with 2gigs of RAM. When I get info on the Illustrator App, there isn't a rosetta option. To be clear, I'm

  • Push data from PSA to info target in bi 7.0

    Hi, i am doing delta update with option only PSA, now data is coming in to the PDA but how to pass it that data form here to res info target? Best regards, dushyant.