How can I read an input, for example: "Enter number of years: "?

I am not really "new" to Java, but for a long time I have been using a book that comes with TerminalIO.KeyboardReader and I need to get input without using that class.
I just need the class required really, but the actual instantiation and the line with the question would be great as well.

One solution is to use java.util.Scanner: [http://java.sun.com/docs/books/tutorial/essential/io/scanning.html]

Similar Messages

  • How can i read user input value to my User exist

    Hi Guru's,
    I am facing one problem in Variables in BPS.
    I am calculating days from Month/year .I have one variable it is for Days,Second variable it is for Month/Year.
    First variable is user exist (for calculating the days),Second varible is user defined variable(this is a Input to the first variable).
    When i am giving the Month/Year(02/2008)variable i am getting the 29 days from the first variable.again i am changing the value of Month/Yera(03/2008) i am not getting the desired value.
    my doubt is my user exist not able to read current value of variable(month/year).how can i pass my value to user exist because this value is user input value based on this value i am calculating the days and dynamically displaying the layout.
    Here is the my sample code..
    seq = '0000'.
    ind = 0.
       i_area = 'ZTEST1'.
       area_var = 'ZVar2'.
    PERFORM instantiate_object USING    i_area
                                        area_var
                                 CHANGING lsr_var.
    PERFORM get_current_value_of_variable
                            USING lsr_var
                            CHANGING lto_value.
    READ TABLE lto_value INTO lso_value index 1  .
    i_month = lso_value-low.
    iv_month = i_month+4(2).
    iv_year = i_month(4).
    concatenate iv_year iv_month '01' into iv_date.
    begindate = iv_date.
    below bracket code calculating the leap year
    ( IF iv_date+4(2) = lc_feb.
        lv_hlp_date_year = iv_date+0(4).
        lv_hlp_rest      = lv_hlp_date_year MOD 4.
        IF lv_hlp_rest = 0.
          EV_DAYS = lc_days_29.
          lv_hlp_rest = lv_hlp_date_year MOD 100.
          IF lv_hlp_rest = 0.
            lv_hlp_rest = lv_hlp_date_year MOD 400.
            IF lv_hlp_rest NE 0.
              EV_DAYS = lc_days_28.
            ENDIF.
          ENDIF.
        ELSE.
          EV_DAYS = lc_days_28.
        ENDIF.)
      ELSE.
    below bracket code calculating the days
    (   CASE iv_date+4(2).
          WHEN lc_jan. EV_DAYS = lc_days_31.
          WHEN lc_mar. EV_DAYS = lc_days_31.
          WHEN lc_may. EV_DAYS = lc_days_31.
          WHEN lc_jul. EV_DAYS = lc_days_31.
          WHEN lc_aug. EV_DAYS = lc_days_31.
          WHEN lc_oct. EV_DAYS = lc_days_31.
          WHEN lc_dec. EV_DAYS = lc_days_31.
          WHEN lc_apr. EV_DAYS = lc_days_30.
          WHEN lc_jun. EV_DAYS = lc_days_30.
          WHEN lc_sep. EV_DAYS = lc_days_30.
          WHEN lc_nov. EV_DAYS = lc_days_30.
          WHEN OTHERS.   CLEAR EV_DAYS.
        ENDCASE.)
      ENDIF.
    data: st_date(2) type c.
    st_date = '01'.
    ind = 0.
    ind = ind + 1.
    here i am passing the low value and high value.
    yto_charsel-chanm = '0CALDAY'.
    yto_charsel-seqno = 1.
    yto_charsel-sign  = 'I'.
    yto_charsel-opt   = 'EQ'.
    yto_charsel-LOW = st_date.
    yto_charsel-chanm = '0CALDAY'.
    yto_charsel-seqno = 1.
    yto_charsel-sign  = 'I'.
    yto_charsel-opt   = 'BT'.
    yto_charsel-high = ev_days.
    INSERT yto_charsel INTO sto_charsel INDEX ind.
    ETO_CHARSEL = sto_charsel.
    lto_value = sto_charsel.
    How can i pass user input value to read this exist ,some where again i have to write code or else??
    This is very urgent can you help me..

    Hi,
    Instead of two perform statements, use single perform.
    PERFORM get_value USING i_area
                              i_variable
                         CHANGING lw_varsel.
    Take the values from lw_varsel-low.
    FORM statement for this perform is as follows.
    DATA: li_varsel TYPE STANDARD TABLE OF upc_ys_api_varsel,
            lv_varsel TYPE REF TO cl_sem_variable.
      FORM get_value USING p_area TYPE upc_y_area
                           p_variable TYPE upc_y_variable
                     CHANGING
                           p_lw_varsel TYPE upc_ys_api_varsel.
        CALL METHOD cl_sem_variable=>get_instance
          EXPORTING
            i_area       = p_area
            i_variable   = p_variable
             I_CREATE     =
          RECEIVING
            rr_variable  = lv_varsel.
           EXCEPTIONS
             NOT_EXISTING = 1
             others       = 2
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        REFRESH li_varsel.
    ****Getting the Value*********
        CALL METHOD lv_varsel->get_value
          EXPORTING
            i_user     = sy-uname
            i_restrict = 'X'
          RECEIVING
            rto_value  = li_varsel.
        CLEAR : p_lw_varsel.
        READ TABLE li_varsel INTO p_lw_varsel INDEX 1.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
      ENDFORM.                    "get_value
    Try this code.
    Bindu

  • How can I read mail attachment for making it to the payload?

    Hi everybody,
    in the following my scenario:
    I have an incoming message with attachment by the mail sender adapter using PayloadSwapBean (because of other messages I have to use the bean). I want to send this attachment by using the mail receiver adapter to fix E-mail-address keeping the FromMailAddress, the MailSubject and the FileName
    without the metadata as additional attachment.
    I have found a thread where it is explained how to handle "payload as mail attachment and dynamic filename" by java-mapping. So far so good. My question is: How can I make my attachment to be the payload? How can I read the attachment by java-mapping?
    Thanks for help.
    Reagrds,
    Sebastian Linke

    USe payloadSwapBean for this to swap your payload and attachment
    /people/michal.krawczyk2/blog/2005/12/18/xi-sender-mail-adapter--payloadswapbean--step-by-step
    Rajesh
    Edited by: Rajesh on Feb 5, 2009 5:29 PM

  • How can I get Pantone colours (for example PMS 285) back in CS6 Illustrator?

    Pantone colours (for example PMS 285) are not available in CS6 ( Illustrator and Indesign). How can I get the right colours back?

    Are you certain they are not available?
    Mike

  • How can I read an input which only contain the 26 upper case letter

    Are there any method that can read an input which only contain 1 character and it is in upper case too.
    should I use readChar( ), or readString( )??
    How should I implement them if I do use one of them?
    thx

    Try this :
    import java.io.*;
    public class Read
    public static void main(String[] x)
    System.out.println("Upper case char typed : "+readUpperCaseChar());
    public static char readUpperCaseChar()
    // method that read char and return the last upper case char
    char x='\0',tmp='\0';
    try
    while(tmp!='\n')
    tmp=(char) System.in.read();
    if(tmp >= 'A' && tmp <= 'Z')
    x=tmp;
    catch(IOException ioex)
    ioex.printStackTrace();
    return x;

  • HT4859 how can i restore only contacts for example from icloud backup of my ipad?

    how can i restore only contacts that have been backed up from my ipad to icloud backup?

    You cannot... See this discussion...
    https://discussions.apple.com/message/17507130#17507130
    Also see Contacts here  >  http://help.apple.com/icloud/?lang=en
    And here  >  http://www.apple.com/support/icloud/contacts/

  • How can I read out metadata for captions from a Canon photo

    I have to tried to find an answer via Adobe and Google. Still not able to figure out on how to read out XMP metadata for captions out of my photos. Checking the XMP data in InDesign shows info on Camera Make, Exposure etc. But if I use metadata fields from "Caption Setup" like "Camera" the caption shows <No data from link>. Fields where the XMP field name matches (e.g. "Lens") are ok. I need following fields for the caption: Camera Make, Exposure (aperture and speed) and ISO.

    Lets keep it simple then.
    If I take my utf file generated and open and view it in notepad I can see the accented characters. But if I open it in Wordpad , the accented characetrs are corrupted.
    If I then save the file specifiying type Ascii, then the characters are written out correctly.
    What I want to do is to be able to write out the file in ascii format without having to open it in utf-mode and then having to save it in ascii.
    Ie I want the file to be opened in ascii format
    All the characters to be written in Ascii format
    But the source is still a unicode database.
    I have gone through using convert and characters get lost. In fact, at this stage, I'm not sure its possible to do What I need to do.
    Remember I am using an 8 bit character set which is why I have values above 127.
    So basically if you take the word 'Annulé'
    if I view it in wordpad it displays as
    Annulé
    But if I view it in notepad it displays as
    'Annulé' which is because notepad detects that the file has a utf-8 character in it.
    When I save it as type ascii I can then open it correctly in wordpad.
    So I basically want to open this file in Wordpad and have it display Annulé rather than the garbled characters,
    without having to go through the process of opening and saving the file as type ansi.

  • How can I cancel my subscription for "Acrobat Pro subscription (1 year)" ??? Pleeeaaase !! It's an emergency

    Can you tell me how to stop it please ? What are the steps precisely ?

    Cancel http://helpx.adobe.com/x-productkb/policy-pricing/return-cancel-or-change-order.html
    -or by telephone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

  • How can we benefit from WebDynpro for ABAP over Normal ABAP

    Dear Guru's,
    Please guide me what are +Ves of WebDynpro over Normal ABAP. Once all Applications are developed how can we organize them. For Example In SD module there is sequence of Tcodes to be executed this is true for all modules . Is there any concept involved in this new technology.
    For What purpose we can suggest someone to implement in an Organization.
    Many Thanks in Advance.
    Regards
    Ram

    Hi Ram,
    Here Are some comparisions I made w.r.t Webdynpro for ABAP (also some benifits over Java):
    1     "Pros:it will be easier to move your development project through the system landscape if both the UI and business logic are in the same development environment.(Update: This is is less of a concern now that CTS+ lets you bundle your WD Java UI developement with ABAP development objects into a single transport, with SPS13. )
    2     tons of custom ABAP business logic is easier to access via WD for ABAP
    3     WD for ABAP has a code wizard, so easy to build
    4     SAP List Viewer and ALV handled better
    5      The biggest thing is the NWDI. Most of the SAP customer have ABAP stack, but not everyone has the Java stack. To develop WD Java you need to set up the NWDI envrionment, like SLD, CMS, CBS, DTR, etc. which is a huge effort if you don't have them in place. While for WD ABAP, the environemnt is normally there as given for most of customers if they have the right version.
    6     If your business is in SAP system, I would prefer WD ABAP. There are many WD components available in WD ABAP like select-option, Alv table, F4-help which are not available in WD Java. Beside in WD ABAP you can deal the context node in form of internal table which is much more performant than dealing with the contextelement which is the case for WD Java.
    Regards,
    Tanaya
    Edited by: Tanaya A on Dec 10, 2009 6:19 PM

  • How can I read Extended APDU input to the same buffer

    The following is the code I am currently using where inBuffer is an intermediate array of 1000 length. However, I do not want to allocate any buffers at all, and just want to send a command apdu of 1000 byte length and modify it in the code and return the modified buf in the response APDU.
    // Read extended APDU input
    byte[] buf = apdu.getBuffer();
    short bytesRead = apdu.setIncomingAndReceive();
    short dataOffset = apdu.getOffsetCdata();
    // store first chunk in our intermediate byte array <-- how do i get rid of the intermediate array
    Util.arrayCopyNonAtomic(buf, dataOffset, inBuffer, (short) 0, bytesRead);
    // what is the overall length?
    short overallLength = apdu.getIncomingLength();
    short messageOffset = bytesRead;
    if (bytesRead != overallLength){ // otherwise we're finished, all bytes received
         short received = 0;
         do{
                   received = apdu.receiveBytes((short)0);
                   Util.arrayCopyNonAtomic(buf, (short)0, inBuffer, messageOffset, received);
                   messageOffset  += received;
              } while(received != 0);
    * REST OF CODE IN PROCESS METHOD
    I have also tried replacing the above code with the following
    short bytesLeft = (short) (buffer[ISO7816.OFFSET_LC] & 0x00FF);
    if (bytesLeft < (short)55) ISOException.throwIt( ISO7816.SW_WRONG_LENGTH );
    short readCount = apdu.setIncomingAndReceive();
    while ( bytesLeft > 0){
      // process bytes in buffer[5] to buffer[readCount+4];
      bytesLeft -= readCount;
      readCount = apdu.receiveBytes ( ISO7816.OFFSET_CDATA );
    as shown in the javadocs API, but it does not compile.
    This is my command APDU:
    /send 800100000003E8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003E8
    As you can see:
    CLA - 80
    INS - 01
    P1 & P2 - 00
    LC - 0003E8
    Data - 1000 0s
    LE - 03E8
    I am using JavaCard 3.0 with JCOP in Eclipse. How can I read the extended length apdu to the same buffer? I have no problem in returning an extended length response APDU. Thanks a lot for the help.

    You should not call the convenience method setIncomingAndReceive() in your first code. Please find out about the different APDU states. Furthermore, your Applet should implement the ExtendedLength tagging interface.

  • How can i read local excel file into internal table in webdynpro for abap a

    Could someone tell me how How can i read local excel file into an internal table in webdynpro for abap application.
    thank u for your reply

    Deep,
    File manuplations...............................
    1. At the presentation level:
    ->GUI_UPLOAD
    ->GUI_DOWNLOAD
    ->CL_GUI_FRONTEND
    2. At the application server level:
    ->OPEN DATASET : open a file in the application server for reading or writing.
    ->READ DATASET : used to read from a file on the application server that has been opened for reading
    -> TRANSFER DATASET : writing data to a file.
    -> CLOSE DATASET : closes the file
    -> DELETE DATASET : delete file
    If file is on the local PC,use the function module GUI_UPLOAD to upload it into an internal table by passing the given parameters......
    call function 'GUI_UPLOAD'
    exporting
    filename = p_file
    filetype = 'ASC'
    has_field_separator = '#'
    tables
    data_tab = t_data
    p_file : excel file path.
    t_data : internal table
    <b>reward points if useful.</b>
    regards,
    Vinod Samuel.

  • I downloaded the ipad app for kindle, my wife has the app on her iphone also with several books that she has downloaded to her iphone, how can i read these books on my ipad?

    I downloaded the ipad app for kindle, my wife has the app on her iphone also with several books that she has downloaded to her iphone, how can i read these books on my ipad?

    By sharing the same Amazon account on each device. You may also have to use the same Apple ID and password.

  • How can I read the trace data into LabVIEW for E5071B

    HI 
    I am setting up the measurement using vector network analyzer (VNA) E5071B controlled by NI 488.2. How can I read the trace data into LabVIEW and display on the graph? If anyone having an idea or know well about this process please give me the suggestion, I will much appreciate it.
    Many Thanks

    You want to start with the driver
     In case you do not know it, you can do the driver search in LabVIEW from Tools>Instrumentation>Find Instrument Drivers. You might also want to bookmark the Instrument Driver Network for information on what a driver is and how to use it.

  • ICal does not allow me to edit "minutes" in the appointments. when i make an appointment it defaults it to xxhrs 08mins (example 16:08) how can i make an appointment for 16:00 or 15:30 hrs ...etc.

    iCal does not allow me to edit "minutes" in the appointments. when i make an appointment it defaults it to xxhrs 08mins (example 16:08) how can i make an appointment for 16:00 or 15:30 hrs ...etc.

    Hi,
    You can change this in System Preferences, Language & Text.
    Go to System Preferences > Language & Text > Formats tab and change where it says Custom to your location. Then re-open iCal.
    Let us know how it goes.
    Best wishes
    John M

  • How can i pass the Input value to the sql file in the korn shell ??

    Hi,
    How can i pass the Input value to the sql file in the korn shell ??
    I have to pass the 4 different values to the sql file and each time i pass the value it has to generate the txt file for that value like wise it has to generate the 4 files at each run.
    can any one help me out.
    Raja

    Can you please more elaberate., perhaps you should more elaberate.
    sqlplus is a program. you start it from the korn shell. when it's finished, processing control returns to the korn shell. the korn shell and sqlplus do not communicate back and forth.
    so "spool the output from .sql file to some txt file from k shell, while passing the input parameters to the sql file from korn shell" makes no sense.

Maybe you are looking for