Writing a string

how to write a large string in java . here is the example:
"select region_id, country_code, product_id,"+
"prov_activity_grp_name, process_order , prov_activity_id,"+
"prov_activity_name, is_merged, is_critical, group_id, group_name, precedessor_id, min_lt, max_lt,"+
� "ltc_utility.next_working_day(country_code, ?, ltc_utility.total_days(sys_connect_by_path(nvl(max_lt, 0), '/'), level) - decode(nvl(max_lt, 0), 0, 1, 0)) start_dt,"+
� "ltc_utility.next_working_day(country_code, ltc_utility.next_working_day(country_code, ?, ltc_utility.total_days(sys_connect_by_path(nvl(max_lt, 0), '/'), level) - decode(nvl(max_lt, 0), 0, 1, 0)), decode(nvl(max_lt, 0), 0, 0, max_lt - 1)) end_dt" +
   "from (select a.region_id, a.country_code, a.product_id,� a.seq_no, a.prov_activity_id,"+
������� "c.prov_activity_name,a.min_lt, a.max_lt, a.is_merged, a.is_critical, f.prov_activity_grp_id,"+
������� "g.prov_activity_grp_name, f.precedessor_id, f.process_order,"+
������� "stragg(d.group_id) group_id, stragg(e.group_name) group_name"+
����� "from step_interval_master a,"+
���������� "(select region_id, country_code, product_id, max(version_no) version_no"+
����������� "from step_interval_master_version"+
����������� "where status_code = 50"+
����������� "group by region_id, country_code, product_id) b,"+
���������� "prov_activity_ref c,"+
���������� "(select distinct prov_activity_id, group_id"+
����������� "from product_prov_act_resp_groups"+
����������� "where country_code = ? and product_id = ?) d,"+
���������� "responsible_groups e,"+
���������� "product_prov_activities f,"+
���������� "prov_activity_group_ref g"+
����� "where a.region_id = b.region_id"+
������� "and a.country_code = b.country_code"+
������� "and a.product_id = b.product_id"+
������� "and a.version_no = b.version_no"+
������� "and a.service_type_id = (select decode(service_type_id, 3, 2, service_type_id)"+
���������������������������������� "from ltc_detail_service_types"+
��������������������������������� "where dservice_type_id = &serv_id)"+
������� "and a.main_order_sub_cat_id = ?"+
������� "and a.country_code = ?"+
������� "and a.product_id = ?"+
������� "and a.prov_activity_id = c.prov_activity_id"+
������� "and a.prov_activity_id = d.prov_activity_id(+)"+
������� "and d.group_id = e.group_id(+)"+
������� "and b.region_id = f.region_id"+
������� "and b.country_code = f.country_code"+
������� "and b.product_id = f.product_id"+
������� "and b.version_no = f.version_no"+
������� "and f.prov_activity_id = a.prov_activity_id"+
������� "and f.prov_activity_grp_id = g.prov_activity_grp_id"+
����� "group by a.region_id, a.country_code, a.product_id, a.seq_no, a.prov_activity_id, c.prov_activity_name,"+
������������� "a.min_lt, a.max_lt, a.is_merged, a.is_critical, f.prov_activity_grp_id,"+
������������� "g.prov_activity_grp_name, f.precedessor_id, f.process_order"+
�����         "order by f.process_order ) t"+
"start with precedessor_id is null connect by prior prov_activity_id = precedessor_id"+
"order by process_order;"

Well you haven't got any spaces between words on separate lines, e.g....
"and b.product_id = f.product_id"+
"and b.version_no = f.version_no"+
...will become"and b.product_id = f.product_idand b.version_no = f.version_no"it should be...
"and b.product_id = f.product_id "+
"and b.version_no = f.version_no "+
...It's a good idea to print such long strings to stdout and check that it's correct.

Similar Messages

  • Troubles writing a string of numbers in binary mode to a file.

    Hi,
    I have a string stringRW = "1234567890". I want to write this numbers to a binary file. For that, I am doing this:
    fileDestiny = new File(arquivo);
    o = new FileOutputStream(fileDestiny);
    out = new BufferedOutputStream(o);
            int i = 0;
            int x;
            while ((x = stringRW.codePointAt(i)) != -1) {
                try {
                    out.write(x); // Copia o arquivo.
                    System.out.println("byte = "  +x);+
    +            } catch (IOException ex) {+
    +                Logger.getLogger(ArquivoEscreverBin.class.getName()).log(Level.SEVERE, null, ex);+
    +            }+
    +            i++;
    out.close();Actualy, I am getting some Exception:
    Exception in thread "Thread-3" java.lang.StringIndexOutOfBoundsException: String index out of range: 11
            at java.lang.String.codePointAt(String.java:715)
            at jserialrwxn.ArquivoEscreverBin.write(ArquivoEscreverBin.java:46)
            at jserialrwxn.NewSerialX.setDados(NewSerialX.java:890)
            at jserialrwxn.SerialComRW.serialEvent(SerialComRW.java:276)
            at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732)
            at gnu.io.RXTXPort.eventLoop(Native Method)
            at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1575)But the problem in fact, is that the generated file is not a binary file. For check if the generated file is or not binary, I do open it in Notepad. When I do open the generated file with Notepad I can read it normaly and see the numbers 1234567890.
    Some one have some guess on how I need to proceed?
    Edited by: cstrieder on Aug 5, 2009 1:15 PM

    cstrieder wrote:
    Hi,
    I have a string stringRW = "1234567890". I want to write this numbers to a binary file. For that, I am doing this:Are you saying that you want to write the individual characters of your string to a file? Or are you saying that you want to write the integer values from your string to a file? I.e., do you want to write the number "1" as a character or do you want to write the value 1 to a file?
    >
    fileDestiny = new File(arquivo);
    o = new FileOutputStream(fileDestiny);
    out = new BufferedOutputStream(o);
            int i = 0;
    int x;
    while ((x = stringRW.codePointAt(i)) != -1) {
    try {
    out.write(x); // Copia o arquivo.
    System.out.println("byte = "  +x);+
    +            } catch (IOException ex) {+
    +                Logger.getLogger(ArquivoEscreverBin.class.getName()).log(Level.SEVERE, null, ex);+
    +            }+
    +            i++;
    out.close();Actualy, I am getting some Exception:
    Exception in thread "Thread-3" java.lang.StringIndexOutOfBoundsException: String index out of range: 11
    at java.lang.String.codePointAt(String.java:715)
    at jserialrwxn.ArquivoEscreverBin.write(ArquivoEscreverBin.java:46)
    at jserialrwxn.NewSerialX.setDados(NewSerialX.java:890)
    at jserialrwxn.SerialComRW.serialEvent(SerialComRW.java:276)
    at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732)
    at gnu.io.RXTXPort.eventLoop(Native Method)
    at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1575)
    Your exception is telling you exactly what the problem is. Your index is beyond the length of your string. Instead of using a while loop to iterate over the String, try using a for-loop instead. i.e.
    for(int i = 0; i < myString.length(); i++) {
      // blah blah blah
    But the problem in fact, is that the generated file is not a binary file.Every file is a binary file. What you're doing is writing the character value to the file. Instead of that, you may want to try parsing your character value into an integer and then writing that value.
    For check if the generated file is or not binary, I do open it in Notepad.That's not an appropriate method for determining the byte values written to your file(s). Use a hex editor instead.
    When I do open the generated file with Notepad I can read it normaly and see the numbers 1234567890.Again, that's because you're writing the character values, not the integer values.

  • Writing a string into a text file

    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.PrintStream;
    public class Main {
    public static void main(String[] args) {
    String result;
    result = "testtest";
    try {
    PrintStream ps = new PrintStream(new FileOutputStream("D:\\test\\output.txt"));
    ps.println(result);
    ps.close();
    } catch (Exception e) {
    System.out.println(e);
    I have a couple of string to write into text file
    ---- for example--
    String test1="aaa";
    String test2="bbbb";
    String test3="c";
    String test4="dd";
    --- condition to write into text file....
    test1 has to write between 1 - 5 position.
    test2 has to write between 6 - 15 postition.
    test3 has to write between 16 - 10 position.
    test4 has to write between 11 - 15 position.
    how can i write those strings into a certain position?
    how can i write those strings for 3 times in a text file?(make 3 rows)

    figure out how write them into a string, then use my helper util class like this:
    String str = "some\nstuff\nhere";
    ASCIIFile file = new ASCIIFile("c:/somefile.txt");
    file.setContents(str);
    //done, file written!code for ASCIIFile can be found here:
    http://www.doesthatevencompile.com/current-projects/code-sniplets/ASCIIFile.htm
    change its package to work with your codes

  • Writing BOLD string to the PrintWriter object

    Hi,
    Following is my code:
    response.setContentType("application/vnd.ms-excel");
    PrintWriter pw = response.getWriter();
    String str = "Developer Forums";
    /* what manipulation is required to the string so that it can we converted to bold font..
    *.NO HTML tags are allowed.
    pw.print(str);

    Makrand.Ubale wrote:
    response.setContentType("application/vnd.ms-excel");Slow there! You can't simply write stuff to a Writer and hope that it's in the correct format for Excel.
    The problem is that Excel accepts some plain-text formats such as CSV as well and many then think that this approach produces a valid Excel file. It does not!
    Especially you can't have any kind of formatting (and I assume even equations) in a CSV file.

  • Non-Blocking Writing and Strings

    Hello.
    My question is simple, is it possible to write strings using a non-blocking method?
    I was praying that there was a method in the NIO API that allowed me to, yet i can't find one.
    If the answer is blatantly obvious please forgive me, i'm tired and hungry :)
    Thank you for looking at this topic

    Strings are written to files or sockets using a certain encoding. I usually use UTF-8, but your application might be different.
    1. Get the SocketChannel from your non-blocking socket.
    SocketChannel ch = mySocket.getChannel(); // mySocket is java.net.Socket2. Make a CharBuffer out of the String you want to send.
    CharBuffer chars = CharBuffer.wrap(myString); // myString is your data3. Encode it so it becomes a ByteBuffer. I'll use the [UTF-8|http://www.joelonsoftware.com/articles/Unicode.html] Charset here.
    ByteBuffer bytes = Charset.forName("UTF-8").encode(chars);4. Use the write(ByteBuffer) method in the SocketChannel from 1.
    ch.write(bytes);Import declarations:
    import java.nio.channels.SocketChannel;
    import java.nio.CharBuffer;
    import java.nio.ByteBuffer;
    import java.nio.charset.Charset;s

  • Writing a String to the Parallel Port

    I am a new user of Labview and have very little experience. I am trying
    to write an arbitrary string (that I can input) to the parallel port.
    Basically, I need to communicate with a device that connects to it and
    will accept commands as plain strings. I have read the article "using
    the parallel port with labview" but it hasn't helped me as I am so
    inexperienced. I was hoping that someone could help to learn how to do
    this and if there's a vi that already does this. It seems like a simple
    enough task. Thanks.

    Rather than simply present an answer from which you will learn little, I will try and out line what it is that you should investigate......
    First have a look at a string control
    You might want a button and a case structure to tell the code when to start decoding the string
    Put the following code inside the case structure say on the true state
    Then, taking data from this string control get the strings length
    Then using this and a loop index through the string using the string subset VI on the string pallette, use the length of 1 and index the position in the loop
    Now figure out how to convert the character to an ASCII value
    Send this to the parallel port
    This should be a reasonable frame work to empower you to learn for yourself.
    "Give a man a fish and you feed him for a day, teach a man to fish and you feed him for life", enjoy the free meals!
    Message Edité par Conseils le 07-13-2006 09:17 PM

  • Writing a String[] in one String

    Hi all,
    I tried to write this Method:
    public String stringFieldToString (String[] strf)
    But I cant get the Paramter String[]. following Error message apppeared:
    pze\InitServlet.java:72: stringFieldToString(java.lang.String[]) in pze.InitServlet cannot be applied to (java.lang.String)
    System.out.println("langer String: "+ stringFieldToString(kommen[count]));
    ^
    Thanx in Advance
    robert

    stringFieldToString(String[] strf); is expecting an array of strings:
    You dont saya how kommen is declared but I think kommen[count] is a single string.
    If kommen id defined thus String[] kommen, then you can pass that to the routine:
    stringFieldToString(kommen);
    hope this helps.

  • Reading/writing a string to a bytearrayoutputstream

    I have a small problem whereby
    I want to write a string over a socket, but i want to do this using a bytearrayoutputstream.
    My outputting is done like so
    // CLIENT SIDE
    DataOutputStream output = new DataOutputStream ( socket.getOutputStream());
    // Fill up a byteArrayOutputstream so it contains 2 strings
    // FileLocation and Ip_address
    ByteArrayOutputStream tempbuffer = new ByteArrayOutputStream();
    DataOutputStream buffer = new DataOutputStream( tempbuffer );
    buffer.writeBytes(fileLocation);
    buffer.writeBytes(ip_address);
    buffer.flush();
    byte[] byteArray = tempbuffer.toByteArray();
    int length = byteArray.length;
    output.writeInt(length);
    output.write(byteArray);
    I then want to read in the bytearray at the server and separate it back out ...
    // SERVER SIDE
    // Read in the length of the byte
    int length = input.readInt();
    byte[] fileInfoByte = new byte[length];
    input.read(fileInfoByte);
    ^^^^^^^^^^^^^^^^^^^^^^ - this works fine
    // Separate the information out of the bytearray
    ByteArrayInputStream bytesIn = new ByteArrayInputStream(fileInfoByte) ;
    DataInputStream dataIn = new DataInputStream(bytesIn);
    There seems to be no opposite of DataOutputStream.writeBytes() method
    So i can read the information out of the bytearray ....
    How can i separate out the strings from the bytearray ??
    Much appreciated ..
    M

    In fact, you just need one more steps. All you did before just specified the whole length of the file location and ip address.
    In my coding I will simply do as
    DataOutputStream output = new DataOutputStream(socket.getOutputStream());
    output.writeInt(fileLocation.length());
    output.writeBytes(fileLocation);
    output.writeInt(ipaddress.length());
    output.writeBytes(ipaddress);At the server side, I will simply
    int length = input.readInt();
    byte[] fileInfoByte = new byte[length];
    input.read(fileInfoByte);
    length = input.readInt();
    byte[] ipaddressByte = new byte[length];
    input.read(ipaddressByte);

  • Help me in writing ajax string search from database

    {noformat}*hi everybody,
    please send me a ajax with jsp application
    suppose i enter a word in text area ajax will populate/suggest all string from database ,who started
    from that entering character(s).like a google string search.
    please send full source code
    *{noformat}

    shadab_think_globally wrote:
    {noformat}*hi everybody,
    please send me a ajax with jsp application
    suppose i enter a word in text area ajax will populate/suggest all string from database ,who started
    from that entering character(s).like a google string search.
    please send full source code
    *{noformat}how about you do it yourself?

  • Writing a string to a file on a web Server

    Hi all,
    i need to write a string of length say 200 chars in a file located on my local apache web server.
    I have an applet that registers username and password +some other information in a string.
    So i need to write this string to a new file every time a new user logs in with a new file name.
    I have this perl script but i dont know how to modify it
    #c:\perl\bin\perl.exe
    # wdwrite
    # this is the CGI that will take the # applet info and write it to a file
    open(OUT, ">> C:/Program Files/Apache Group/Apache2/giorgi/JCachesim/logs/log.txt");
    print "content-type: text/plain\n\n";
    while (<>) {
    print OUT $_;
    print $_;
    close (OUT);
    exit 0;
    And also what do i need to do to call this script (actually not this,the modified one) from my applet?
    I have some snippets of java code but i dont think they work for my case.
    Can you help me?
    Thank you very much,
    Chris

    If it's a perl script, then you can execute it as a CGI or apparently using mod_perl, which I've never worked with. In either case, it's not really a java question; it's a Perl or Apache admin question and you'd probably get better responses on forums for those.
    You can invoke it by opening an HttpURLConnection to it, at whatever path the script lives on at the server.

  • Writing exponential string with two-digit exponent

    I have to create a text input file with a very specific format from LabView, the numbers to be expressed in exponential notation with a two-digit exponent term, padded with a leading zero if required(i.e. 1.2345E+01 instead of the LabView default 1.2345E+1) I was wondering if anyone had found a built-in way to do this, or if I need to write my own string modification function. Thanks!

    No dedicated LV function to do that. But the solution is not very complicated. See the attached vi.
    May be this time, I'll be the first to answer (private joke )
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Format_Exponent.vi ‏20 KB

  • String Data-Loss over Sockets

    I have some code that sends strings through a socket to a C++ program on another machine.
    The test strings I have been using are three characters long (i.e. 6 bytes). The buffer size I have put on the socket is 72 bytes, so I should have no problem writing these strings.
    The first three strings always arrive at the other program fine, BUT after that, only a substring of each string seems to get through. I am absolutely certain that the strings are complete before I send them, because I print it to the screen at the same time.
    I have tried change the style of output stream I use (I have used DataOutputStream, BufferedOutputStream, BufferedWriter, StringWriter, and PrintWriter. It still happens.
    Can anybody tell me why this might happen?
    - Adam

    Without more info it is hard guessing. If you want
    reassurance that it should work, then yes, it should
    work.-(Well that's kinda what I'm looking for. I'm wondering if anybody knows of a reason why a C++ program (running in windows -- btw, not by my choice) would read the string differently than a java program?
    For all the XxxWriter types you used, I hope you
    declared the charset to be one that preserves the
    2bytes/char you expect (UTF-8 and ISO8859-1 aren't).I haven't modified that from whatever default is set. This may be the probelm, I will look into that, thanks.
    You certainly did not use the BufferedOutputStream
    without somehow encoding the characters into bytes,
    so how did you do? I'm not sure (it was last week that I tried it) but I think the BufferedOutputStream has a method writeBytes(String) that I used.
    For DataOutputStream, I hope you
    used writeChar, which guarantees that 2bytes/char are
    send. Nope. I mostly tried to stick with methods that accept a String, so that I was sure that it was sent out in the right format to be read back in as a String. I wasn't sure what the actually format of a String is, when passed through a socket, specifically, if there is a terminating character (I know C uses a \0 to end the string). Is there any additionl info need to write a string to a socket?
    If you did all this, ... well I would not
    fiddle with the socket's buffer size.Sorry, but I may have to maintain a low buffer size, because these strings are not the only things being sent over this socket. Do you think the buffer size is affecting the problem. I wondered, but the buffer size seems more than large enough to send 3 character strings.
    That's all that comes to mind. Did you try netcat
    (aka nc) as a server to make sure the problem is not
    at the receiving end?I haven't tried this yet, but I will if I can't figure this out. Unfortunately, I'm NOT the author of the code that recieves the data, and the guy who is has simply assumed that the problem is my fault (although he's never actually tested his code with the string data being sent before), and is not interested in checking to make sure he's done it right. I tried looking over his code, but he's got the input routine burried in an #include file that I don't have.
    Thanks for the input, Harald. There are a few things there that I will look into.
    - Adam

  • Writing into pdf file

    Hi All,
    I need to add a line of text/string to about
    1000 or so number of pdf files. whats the best
    way of writing this string to the pdf file.
    Has anyone done this using java/javascript.
    If so could you please tell the best solution
    or provide some code samples.
    Thanks
    lared

    I know there is an API available from http://www.adobe.com for java (90% sure). I'd suggest starting there.

  • What's the best way to extract data (a substring) from a string?

    Hi,
    I have a field being returned from a function call and the data looks like this:
    sfaqwe4|89uuuroeoi0|kjg3j90493  (It's data...pipe...data...pipe...data)
    What is the best technique to use to extract the middle set of data between the two pipes?
    Is the any prewritten method to separate the data, or do I have to loop thru the field looking for the pipes, etc.?
    Thanks for your help,
    Andy

    <<Copy paste from http://careerabap.blogspot.com/2009_08_01_archive.html - user notified, points removed>>
    Hi,
    The WRITE statement is what we use to substring a field. The syntax is as follows:
    WRITE fieldname+starting_position(field_length) to variable
    The fieldname is the source (or input). The plus sign precedes the starting position of the substring.  The first position in the string is 0. Immediately after (no space) comes the length of the substring you are going to use. You can also substring the variable that you are writing the string to (the target).
    You can also use function module 'STRING_SPLIT_AT_POSITION'.
    Best Regards,
    Edited by: nihad omerbegovic on Dec 14, 2009 3:03 PM
    Edited by: Matt on Dec 20, 2009 4:13 PM

  • Writing a series of codes to parallel port LPT1

    Currently i'm using Labview version 5 to write a program which sets the individual pins on my LPT1, which i'm sucessful in. However, I notice that after writing an ascii to Serial Port Write.vi, it still doesnt sets the parallel port. It is only when i include close serial driver.vi after writing the string then the respective output is set.
    In my application, i need to send many ascii within a very short time frame, currently, using the above method, for 40 ascii characters that i write into the parallel port, it took the computer about 2 seconds to finish (which is too slow). How do i improve the performance of my application?

    Jared,
    I tried using Out Port.vi but when i key in 378 to the register address and key in the number for the value control and run the vi just for testing purposes, it gives a dialog "Capability not supported. VI 'Out Port.vi' was stopped at Code Interface Node 0x1BC of subVI 'Out Port.vi' . I do not have the advance analysis package and i wonder if it's that is the root of the problem for the mentioned, or have i misintepreted 0x378.
    Thanx for your attention.

Maybe you are looking for