How do you insert a carriage return into a string ?

Hi,
I don't know how to insert a carriage return, \n ,into a string
without the carriage return being interpeted. I am trying to build
a string called queryVariable from the file below so that it equates
to the necessary format for JDBC to execute the query.
SQL script file:
declare @x datetime
select @x = null
exec OSVBAK01...demand_dump PRODUCT,FULL,@x
go     
required string format for query:
"declare @x datetime\n"+"select @x = null\n"+
"exec OSVBAK01...demand_dump PRODUCT,FULL,@x";     
void Readfile(String path, String infilename) {
try {
File file = new File(path + infilename);
     if (!file.exists()) {
     System.err.println("File not found");
     BufferedReader in = new BufferedReader
(new FileReader(file));
     String str;
     String queryVariable = "";
     StringBuffer sb = new StringBuffer();
     while ((str = in.readLine()) != null) {
     sb.append("\"").append(str).append("\n\"")
.append("+");                              
     in.close();
     queryVariable = sb.toString();
     System.out.println(queryVariable);
} catch (IOException e) {
     System.err.println(e.getCause());
queryVariable equates to the following after running the code above:
"declare @x datetime
"+"select @x = null
"+"exec OSVBAK01...demand_dump PRODUCT,FULL,@x
"+"go     
"+
Any assistance anyone could provide would be greatly appreciated.
Thanks for your time,
YAM-SSM

Interesting... that would mean, of course, that in the case of concatenating string literals (outside of loops, as they say), the compiler is optimizing the code to avoid the need for using StringBuffers internally. Actually, it's good to know this, as I wasn't aware of this optimization.
However, the post wasn't meant to be serious... I hoped that was obvious. Everyone's spouting off nearly the same thing for adding strings and line separators and whatever.

Similar Messages

  • How do you insert a submit button into your form?

    How do you insert a submit button into a form?

    Hi,
    The submit button is included automatically. If you are distributing your form as HTML you can use the Test tab to preview your form. If you are distributing your form as PDF, you would need to generate the PDF to see the submit button.
    Regards,
    Brian

  • How do you store input from keyboard into a string array

    I am trying to learn java and one of the programs I am trying to write needs to be able to accept a machine hostname at the keyboard and stuff it into a string array element. I am sure I will be using something along the lines of:
    BufferedReader in = new BufferedReader(new InputStreamReader(
                             System.in));
                   String str = "";
                   System.out.print("Enter a FQDN to look up: ");
                   str = in.readLine();
    but how do I get the input stuffed into hostname[ ].
    Any hints or assistance will be appreciated.
    Michael

    Well part of. I need to be able to take a random number of hostnames (ie. mblack.mkblack.com, fred.mblack.com, joe.mblack.com, ...) and after the user presses the enter key between each entry, the inputted information is stored in an array element. for example with the three shown above the array would look like this after the user finished.
    hostname {"mblack.mblack.com","fred.mblack.com","joe.mblack.com"};
    the algorithm would be
    Prompt for hostname
    get user input and press enter
    store hostname into array element
    prompt for next hostname or enter with no input to complete entry and execute lookup.class methods.
    I have the program written and working fine if I use a static array where I put the hostnames in the list, but cannot figure out how to get the information from the keyboard to the array element.
    Thanks for the help though, the response is very much appreciated.
    Michael

  • How do you insert another PDF document into an existing PDF page

    Here's some background.  I used to use Acrobat 5 (I know it's really old but it worked great for my needs, but it's time to upgrade).  Say I have an existing 1 page PDF document (an Invoice for example).  Sometimes in Excel I create additional supporting details/calculations/etc that I must place onto the Invoice.  In the past I would print my Excel document to PDF using PDF Broadgun (great tool!) - and I'd like to keep doing this.  Then I would go into Acrobat 5, open up my 1 page Invoice PDF document, then I'd use the Form tool, insert Icon, and select my "supporting" PDF document right onto the 1st page.  Then, as needed, I could resize it and place it anywhere on the existing Invoice/PDF 1 page document that I started with, and the resolution was great (i.e. no "grainy" appearances, etc).
    I've now upgraded to Acrobat XI Pro (well, technically I'm trialing to make sure it'll will meet my needs - so far so good, until I ran into this).  I have tried copying the Excel data directly into my PDF Invoice document, but it often times makes the object super large (way off the page left to right) and then I have to resize it (substantially reducing the size) in order to make it fit the page.  This resizing the causes the text to appear "grainy".
    So pretend that my original Invoice/PDF 1 page document took up the top 1/2 of the page.  Then in Excel I create some backup which is say 5-10 lines of calculations.  How can I get the Excel backup as an Image into my original 1 page document (and on 1 page)?  The only work around that I've found so far is to insert it as the last past, then highlight the new stuff from Excel, cut and copy it onto page 1 (these seems like several extra steps in my eyes, but it does work).
    I also want to avoid using screen snip-it, snagit, and various other tools for the following reasons:
    1.  I don't want to remove the grid lines within Excel (i.e. when you print from Excel the grid lines do not print by default)
    2.  I use PDF Broadgun to generate a PDF (i.e. electronic print) and then the data/document looks just like I'd want it to look if I had physically printed it
    Any thoughts?  Many thanks in advance for the help too.
    Other Details:  Windows 7 Pro, company/business use

    I don't see what the problem is with printing to PDF using the Adobe PDF printer as you did with the other tool. Then open your new Excel PDF and do the same process as before (assuming it worked for you). Just go to the Tools>Interactive and add a button field (I assume this is what you did before) and put the file there. At least give it a try as I think that is what you said you used to do.

  • How do you insert a slide show into a page in Fireworks or Dreamweaver CS4?

    Newbie here. I just made a nice 4 image slide show in FW CS4 (under COMMANDS, CREATE SLIDESHOW) but can't figure out how to insert it into a page in FW or Dreamweaver CS4. My goal is to insert it into a FW page, then send it as a PDF to the boss for review before it goes into Dreamweaver. Can that be done? I assume if you can create the slide show in FW, then you can see it FW - or is that asking too much?? So far, I can create it, then choose to preview it in a browser (and it looks good). But then I click "done" and "x" out of the screen and it's gone. I saved the slideshow in a folder I created on my desktop. When I open the folder I see an images folder, a scripts folder, an "index.html", a "player_black.swf", and a "slideshow.xml". I've tried dragging all of these onto the FW page but nothing happens.. Also, the "insert" button in FW doesn't have a preset for slideshows. Neither manual mentions how to insert it into a FW or DW page.. Any help is greatly appreciated.

    Problem solved. Found an import movie within iMovie.

  • How do you insert a CD/DVD into a macbook pro drive?

    Hi, I'm a new user to macbook pro's. I just wanted to ask what should I expect when I first insert a cd into my drive for the first time? I try to put in about 3/4 in with the cd I want to insert, and there are no signs (physical/audible) that the system is recognizing I am trying to put in a CD and take the rest of it in automatically. Are you suppose to just keep jamming the CD completely in without the computer taking it in at all?

    To see if the disc has been charged, open Finder and look under Devices in the sidebar, and you must see the DVD. The MacBook Pro has a slot-in drive, so it should make a noise, but if DVDs load properly and you see it in Finder, don't worry about this

  • How do you insert an iMovie project into a blog?

    I created a new project (my first) in iMovie and would like to insert it into the text of a blog.  I attempted a copy and paste from my desktop, but it did not transmit into a readable format in the blog.
    I am using a MacBook Pro with Mavericks, 2.6 GHz Intel Core processor, with 8 GB 1600 MHz DDR3.
    Thanks very much for any advice.
    Cheers,

    I'm no expert on this but I hink you would have to upload your movie to YouTube or similar then put a link to the movie in your blog.
    Geoff.

  • How to insert a carriage return in a varchar field

    Post Author: gilles
    CA Forum: Data Integration
    Hello,
    How do you insert a carriage return in a varchar field in BODI ? I couldn't find a function like CHAR(13)...
    Thanks
    Gilles

    Post Author: gilles
    CA Forum: Data Integration
    Thanks a lot,
    I'll upgrade to 11.7 (currently 11.5.1)
    Gilles

  • Insert carriage return into string

    can someone tell me how to insert chars like carriage return in to strings in Labview 6.1 ?
    Thanks

    under the string subpallette you will have the ability to use constants for carriages return, tab, etc. Also when on the front panel you can right click on any text indicator or control and select Codes Display. This will allow you to see the /n's. Hope this helps.
    BJD1613
    Lead Test Tools Development Engineer
    Philips Respironics
    Certified LV Architect / Instructor

  • How do you insert an electronically signed report as an appendix into a main report which will be signed electronically at a later date?

    How do you insert an electronically signed report as an appendix into a main report which will be signed electronically at a later date?

    You can add it as a file attachment. Exactly how you do this depends on the version of Acrobat you're using, but if you open the Attachments panel, you should see where you can add a file.

  • How do you insert a picture into another picture?

    How do you insert a picture into another picture.  For example, one person is missing from family photo & I'd like to insert that person's face.

    By using an external editor:
    In order of price here are some suggestions:
    Seashore (free)
    The Gimp (free)
    Graphic Coverter ($45 approx)
    Acorn ($50 approx)
    Pixelmator ($50 approx)
    Photoshop Elements ($75 approx)
    There are many, many other options. Search on MacUpdate. You can set Photoshop (or any image editor) as an external editor in iPhoto. (Preferences -> General -> Edit Photo: Choose from the Drop Down Menu.) This way, when you double click a pic to edit in iPhoto it will open automatically in Photoshop or your Image Editor, and when you save it it's sent back to iPhoto automatically. This is the only way that edits made in another application will be displayed in iPhoto.

  • How do you insert page numbers into a pdf that combines multiple documents?

    I need to combine a number of documents into one PDF that then has correct pagination for the whole new document. How do you insert page numbers when combining into one PDF?

    Hi,
    You can go to Tool panel. Go to Pages. Click on Header& Footer -->  Add & Footer from the Add Header and Footer
    Regards,
    Ajlan Huda.

  • Insert Carriage Return into CLOB

    I'm creating a clob that will be sent via email as an attachment with errors that occur during a package run. How can I send a carriage return so that the lines in the attachment break up and are easier to read?
    This is what I have so far.
    LOOP
    gv_email_body:= gv_email_body ||
    'Amount'||err.amount
    ||'Vendor: '||err.description
    ||'Account: '||err.Acct
    ||chr(13);
    END LOOP;
    gv_email_body is my clob.

    I resolved myself, quite simple.
    chr(10)||chr(13)

  • How do I insert my Edge Animation into Wordpress as an animated/interactive graphic

    How do I insert my Edge Animation into Wordpress as an animated/interactive graphic?

    Hi ColleenSyron,
    Can you check out this video: http://tv.adobe.com/watch/create-like-crazy-with-adobe-edge/episode-5-spice-up-your-wordpr ess-site-with-edge-animate/
    Thanks,
    Preran

  • How can you insert "Page Break" in a pdf file so you will specify the pages

    How can you insert "Page Break" in a pdf file so you will specify the pages

    How / from what was the PDF originally created?  It would be easiest to insert page breaks into the original document, then recreate the PDF.

Maybe you are looking for