To read more than one line...

I 've this code but it can read from keyboard only one line
(when I type enter after the first line an EOF is raised )>
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
      String sql = "";
      System.out.println("Enter your JDBC/SQL query: ");
      try {
         sql = buf.readLine(); Someone can help me so that I can enter more than a line ?
Thanks a lot.

Do you want the user to entry two queries, one per line, or do you want to allow a single query to
be entered on two lines?
What happens when the query is only one line long?
What happens when the user wants to use more than two lines to enter the text?
Suggestion: use a loop and use something simple like a blank line to signal
end of input. It's not hard:
import java.io.*;
public class MultilineInputExample {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(int i=0; i < 2; ++i) {
            System.out.println("Enter multiline input. End with a blank line");
            String input = readMultilineInput(in);
            System.out.println("input = [" + input + "]");
    //uses a blank (white space) line to signal the end
    public static String readMultilineInput(BufferedReader in) throws IOException {
        StringBuilder b = new StringBuilder();
        String line;
        boolean notDone = true;
        while (notDone && (line = in.readLine()) != null) {
            if ((notDone = !line.trim().isEmpty()))
                b.append(line).append(' ');
        return b.toString();
}

Similar Messages

  • Display more than one line of text for events?

    I couldn't find this in the forum... I just recently updated to Leopard. Now when I put events in iCal, it only displays one line of text in the month calendar view. I'd really like to see the whole description of the event, even if it's two or three lines. I can't find anything in preferences that addresses this, and various searches are not yielding anything. Help?
    -mel

    Hi there.
    Usually in iCal if you want more than one line of text for timed events, resizing the window will help. Under all-day events, iCal will always show you one line of text, but if there is more space it will show you more text. So, also resizing the window for this will help to see the text.
    Take care.

  • More than one line beside a category icon

    Hello,
    I have in a page placed the text item category icon, and space a then the display name of the item. The problem is that as the text of the display name is too long when it makes an automatic return makes it under the category icon. It seems to be a problem with the number of text lines that can be placed beside the category icon.
    How can I make that the category icon accepts more than one line of text beside it?
    Thanks in advance,
    Izzat Sabbagh
    ITC

    I'm sure you can use html, like
    String tooltip = "<html>first line<br>second line</html>";Perhaps it works without html if you use newline '\n'.

  • More than one line in a JToolTip

    Hi,
    Is it possible to have more than one line in a JToolTip?
    I think I've seen it done with HTML but I cant remember.
    I did a search but no luck.
    Can anyone help?
    Cheers,
    Jim

    I'm sure you can use html, like
    String tooltip = "<html>first line<br>second line</html>";Perhaps it works without html if you use newline '\n'.

  • Nested If condition in Routine - Literals that take up more than one line

    Hi All,
           I am writing following code at object level of routine but its giving following exception: Please help me on this.
    Exception:
    E:Literals that take up more than one line not permitted.
    CODE:
    IF SOURCE_FIELDS-/BIC/TOTAL >= 900.
        RESULT = 'A.
    ELSEIF SOURCE_FIELDS-/BIC/TOTAL >= 800 AND SOURCE_FIELDS-/BIC/TOTAL < 900.
        RESULT = 'B.
    ELSEIF SOURCE_FIELDS-/BIC/TOTAL >= 700 AND SOURCE_FIELDS-/BIC/TOTAL < 800.
        RESULT = 'C.
    ELSEIF SOURCE_FIELDS-/BIC/TOTAL >= 600 AND SOURCE_FIELDS-/BIC/TOTAL < 700.
        RESULT = 'D'.
    ELSEIF SOURCE_FIELDS-/BIC/TOTAL >= 500 AND SOURCE_FIELDS-/BIC/TOTAL < 600.
        RESULT = 'E'.
    ELSEIF SOURCE_FIELDS-/BIC/TOTAL >= 400 AND SOURCE_FIELDS-/BIC/TOTAL < 500.
        RESULT = 'F.
    ELSEIF SOURCE_FIELDS-/BIC/TOTAL >= 350 AND SOURCE_FIELDS-/BIC/TOTAL < 400.
        RESULT = 'G.
    ELSEIF SOURCE_FIELDS-/BIC/TOTAL >= 300 AND SOURCE_FIELDS-/BIC/TOTAL < 350.
        RESULT = 'H.
    ELSEIF SOURCE_FIELDS-/BIC/TOTAL >= 200 AND SOURCE_FIELDS-/BIC/TOTAL < 300.
        RESULT = 'I.
    ELSEIF SOURCE_FIELDS-/BIC/TOTAL >= 0 AND SOURCE_FIELDS-/BIC/TOTAL < 200.
        RESULT = 'J.
    ENDIF.
    Thanks in advance.
    Anitha.B

    Hi Anitha
    Just check
    RESULT = 'A.
    ELSEIF SOURCE_FIELDS-/BIC/TOTAL >= 800 AND SOURCE_FIELDS-/BIC/TOTAL < 900.
    RESULT = 'B.
    ELSEIF SOURCE_FIELDS-/BIC/TOTAL >= 700 AND SOURCE_FIELDS-/BIC/TOTAL < 800.
    RESULT = 'C.
    Whether it needs to be under two quotes. I feel one is missing. it should be 'A' and not just 'A.
    Regards
    Sriram

  • Simultaneously read more than one input and generate output

    Is it possible To simultaneously read more than one input and generate outputs depending on these inputs? If this isn't possible what is the best way to go about making some sort of timed loop that will read an input, read the next input, decide whether or not to output and so on. Hope someone can help. Thanks.Message Edited by Esmith13 on 05-25-2005 01:36 PM

    Hi,
    You should look at the synchronized examples for analog input and output that can be found in the example finder under:
    Help>>Find Examples>>Hardware Input and Output>>DAQmx>>Synchronization>>Multi-Function
    These will get you started to being able to handle multiple tasks at the same time.
    I hope this helps. Have a Great Day!
    George

  • INDESIGN GLITCH: Creating an XML file from Indesign Layout - Issue "Using more than one line of GREP" & "Map Styles to Tags"

    I currently create XML from InDesign CC by Mapping Style to Tags.
    - The Paragraph Styles are manually apply to text. These styles include multiple lines of GREP to automatically apply character styles.
    - I map some of the paragraph and character styles to prebuilt tags that have the same name "Map Styles to Tags".
    I have found through trouble-shooting that InDesign is unable to "Map Styles to Tags" for more than one line of GREP. I therefore have to chose which line of GREP to automatically tag and which lines to manually tag.
    Please can anyone help, I need to automatically map tags to at least two character styles in one paragraph via GREP.
    Thanks,

    OK. The best I can suggest is running a Find/Change like this:
    Which will actually apply the character style to the italics (and I would do the bold as well just to make certain). Then run the Map Styles to Tags again, using the Apply by Name. Which will tag the italics.
    I don't know why ID can map to the bold and not the italic character style. It either should do them both (as in this instance) or none at all as the character styles are not actually applied by the grep, just the styling from the character styles.
    Mike

  • GL account balance splitting in more than one line item in FSV

    Friends,
    While going through the FSV, gl account balance is splitting in more than one line item with same account name.  But if we total the line items ultimately it is tallying with GL balance.  What might be the reason.  Why it is splitting the balance in more line items with same name and same account number.

    Dear,
    You might be having Document Splitting Activation.with Bussiness Area/ Segment wise/Profit Center Wise. For this please Check - Path > Spro > SAP reference IMG > Financial Accounting (New) > General Ledger Accounting (New) > Business transactions > Document Splitting > Define Document Splitting Characteristics for General Ledger Accounting.
    Please go through this & will  be able see the Document Splitting is based on Bussiness Area/ Segment wise/Profit Center wise or may be both.
    T & R,
    Madhuri Panda

  • When I read a pdf document using Safari I'm unable to read more than one page of a file. A padlock icon is locked on the tab. Please help.

    When I read a pdf document using Safari on my IPad  I'm unable to read more than one page of a file. A padlock icon is locked on the tab. Please help.

    Hi snoreaustralia,
    It sounds like you just need to associate the PDF filename extension with Acrobat, rather than Preview. Please see this document from the Microsoft Help for instructions on choosing the default program for opening a particular file type (in your case, PDF): Change which programs Windows uses by default - Windows Help
    Best,
    Sara

  • Can I expand notifications to read more than 3 lines of text?

    Is there any way to expand the notification center's text to read out more than 3 lines of message text?

    Could you post a screenshot showing what you've got in design mode? That should help us isolate the problem...

  • Modbus, having trouble reading more than one register.

    I think my issue may be something simple. I am able to read exactly one modbus register correctly. If I try to increase the registers to any more than one I get a timeout 6101 error at the Modbus read module. So far I've tried a number of different layouts, and even two different Modbus slaves from different vendors with the same results. I'm using a USB-RS485 converter with the FTDI232 chip. Again, a single register read always returns the correct data - so I'm almost there. The register divide routine on the right had side is rudimentary for now until I can get data from multiple registers. Any help is appreciated.
    Attachments:
    Modbus test.vi ‏37 KB

    I have solved the issue. On my RS485 converter (I'm using one from bb-electronics), I had "Echo on" enabled. This caused the written command to re-appear on the read buffer. The modbus read function will accept this configuration - but only when reading one register! So, for anyone with this issue in the future - check your echo setting.
    Someone more familiar with the modbus protocol's working and the internals of the read function could probably explain why this situation would manifest.
    I understand the timed loop is bad practice - I should loop while no error, but I was trying to fix my core issue before making any improvements.
    Thanks for your help.

  • SELECT INTO SELECT CAN IT ACCEPT MORE THAN ONE LINE ?

    Hi i have a table that i have to fill with information from an old one, but there are two colomns that i have to fill with another table. So here is the select that i will use with the insert part.
    select
    id_migration_mig,
    (select a.id_instance_ins
    from gdiexp.t_instance a, gdiprod.t_migration_detail b, gdiexp.t_bd c
    where a.id_instance_ins = c.id_instance_ins and c.id_base_donnee_bd = b.id_instance_ins_actuelle),
    (select a.id_instance_ins
    from gdiexp.t_instance a, gdiprod.t_migration_detail b, gdiexp.t_bd c
    where a.id_instance_ins = c.id_instance_ins and c.id_base_donnee_bd = b.id_instance_ins_cible),
    type_environnement,
    date_migration,
    donnees_sources,
    date_au_plus_tot,
    methode,
    date_dern_maj_ctrl,
    code_usager_ctrl
    from gdiprod.t_migration_detail;
    problem is that this gives me a ORA-01427: single-row subquery returns more than one row. How can i solve that ? Thanks.

    Your queries in the select clause need to be correlated witt the rows you are selecting from gdiprod.t_migration_detail. You should not need to have gdiprod.t_migration_detail in those queries. I believe that you need something more like:
    select id_migration_mig,
           (select a.id_instance_ins
            from gdiexp.t_instance a, gdiexp.t_bd c
            where a.id_instance_ins = c.id_instance_ins and
                  c.id_base_donnee_bd = md.id_instance_ins_actuelle),
           (select a.id_instance_ins
            from gdiexp.t_instance a, gdiexp.t_bd c
            where a.id_instance_ins = c.id_instance_ins and
                  c.id_base_donnee_bd = md.id_instance_ins_cible),
           type_environnement, date_migration, donnees_sources, date_au_plus_tot,
           methode, date_dern_maj_ctrl, code_usager_ctrl
    from gdiprod.t_migration_detail md;You query, and my re-written version are essentially outer joins, and could be re-written as such. If you are sure that there will always be a match, that is, when oyu insert into your table, the columns populated by the scalar queries are never null, then it could (and probably should) be re-written as a equi-join.
    John

  • How do I scroll more than one line at a time in Firefox 4? Scrolling with down-up keyboard arrows is much faster in IE/Chrome.

    I have tried using about:config options mousewheel.withnokey.sysnumlines > false and custom set mousewheel.withnokey.numlines, but it makes a difference only when I use a mouse, which I don't use most of the time on this laptop. I use down/up keyboard errors to scroll, and the page scrolls one-line-at-a-time, very slow and lagging. Is there a way around this?
    I have reinstalled Chrome as secondary browser only because of this, FF4 otherwise really kicksass. Thank you for an amazing browser and any feedback on my issue.

    Well I am using those, but it is not very practical. What puzzles me is that only Firefox has this behaviour, I have tried last versions of IE, Chrome, Opera - all three scroll much faster than Firefox 4 using down/up keyboard arrows.
    Thanks for the reply, I really hope to get a solution to this.

  • Text variable over more than one line

    Hi,
    I want to use text variables in table cells. But if the content of the variable is to long to fit in one line, then InDesign hides the complete content of the variable. I thing, this is a "no-go" for text variables. What, if it currently fits and then I increase the character size so that it will not fit? Ughhhhh!
    Is there a work-a-round for this problem?
    What do you think about it?
    Should this behaviour changed in future releases of InDesign?
    With Greetings from Germany
    Ralf
    (sorry about my not really good english)

    What I've done in the past is
    Find out how many characters per line.
    Setup character style called VarLine 1, VarLine 2, VarLine 3 etc.
    Set up a paragraph style for your text.
    Go to the nested style.
    VarLine 1 up to # characters
    VarLine 2 up to # characters
    VarLine 3 up to # characters
    etc.
    Set up your Variables for
    Line 1
    Line 2
    Line 3
    Then set each one to pick up the appropriate VarLine character style.
    This works to a certain extent, it will need tweaking, as each application is different. I'm not sure if it will work in your case, but you never know.

  • More than one line on bar chart

    I am creating a Line chart from a table.  The table includes a code column, date column, and several statistic columns. The dates are end of month dates only. There are about 10 different codes for each month.  The statisic columns are the totals for the month for each code.
    PeriodEndDate  Code  Statistic1 Statistic2 Statistic3 Statistic4
    XX/XX/XXXX     XX      999        999        999        999
    On my line chart I want to show one or more statistics for one year for a given code. (A line for each statistic)
    On a different report I want to show one or more codes for one year for a given statistic.  (A line for each code)
    The report has parameters for the code and the statistic. I have figured out how to create the chart for one code for one year for a given statistic.  Can any one help me out?
    Thanks,
    Fred

    Hello Fred,
    If you work with a multi-value parameter you could pass in a collection of x of 10 of your codes. I assume you have played with this idea?
    Perhaps you are stuck because there are no design-time options in the chart design wizards to base your line chart off the numerous values that could be passed into a single multi-value "code" parameter?
    If it is a limitation of the chart design options available to you then your only recourse may be to use one of the SDKs to massage data into a datatable which could be pushed to a report on the fly.
    Cheers, Dylan
    <p><strong>Dylan Lopez - </strong>604.628.4467 </p><p>Previously: Microsoft .NET Resource in Developer Support @ Business Objects</p><p>Currently: Principal @ Inno Software Inc / Independent Contractor Group</p>

Maybe you are looking for