Remove the new line character

Hello All,
I have a CLOB in my database. That CLOB contains new line characters. Now I have to remove the new lines and make the whole CLOB object as a string without the new lines.
Can anybody help in that matter ?.
Thanks and regards,
Sachin

Check this code for file instead of CLOB and reply.
import java.io.*;
import java.io.FileInputStream;
import java.io.InputStream;
public class CLOBCheck {
     public static void main(String[] args) throws Exception {          
          InputStream fis = new FileInputStream("C:\\cpsweb.log");
          BufferedReader d = new BufferedReader(new InputStreamReader(fis));
          StringBuffer sfr = new StringBuffer();
          String line = null;
          int c = 0;
          while((c= fis.read())>-1){
               sfr.append((char)c);               
          System.out.println(sfr.toString());          
          String a = sfr.toString().replaceAll("\n","");
          System.out.println(a);
Thanks,
Sachin

Similar Messages

  • Removing New Line Character in Input file

    Hi Experts,
    I Have a question about "New Line Character". I searched in SDN before posting this thread, But I didn't get answer.
    Question:
    Let me say my Client requirement first. After loading the data(Millions of Records) into SAP through LSMW, they asked write a program for validation of those loaded records based on I/P file. I wrote a program and It is success full.
    But, the problem is when file is in Application server in 'BIN' format, a new line character(#) is created. While comparing the last record of each line, it doesn't match. How to remove this new line character(#) in I/P file for each line of record? Please see the below records for example
    PROVINCIA DE BUENOS AIRE|   |1870|AR| #
    PROVINCIA DE BUENOS AIRE|   |1876|AR| #
    BOX 7407 PRINCETON|   |085437407|US|NJ#
    5756 2 A   CAPITAL FEDERAL|   |1431|AR|00#
    Note: This New line character is not matching the string "#".
    Please help me guys, so many objects are related with this concept. I appreciate quick response. Please.
    Thanks
    Sai

    Hi Arun, Ravi,
    I wrote the code like this, here 'fil_curre' is currency key.
    IF <l_wa_file_data>-fil_curre CS cl_abap_char_utilities=>newline.
              REPLACE ALL OCCURRENCES OF REGEX cl_abap_char_utilities=>newline
                                            IN <l_wa_file_data>-fil_curre WITH ''.
            ENDIF.
    While executing the code, the cursor here, simply jumps to next step.
    Any enhancements to this code or any new ideas?
    Thanks
    Sai

  • How to remove new line character from query output?

    Hi,
    How to remove new line character from query output?
    have tried select replace(column_name, CHR(10), ' ') from table_name.
    Edited by: GreenHorn on Sep 11, 2008 12:53 AM

    Please consider, that windows uses a sequence of chr13||chr(10) Unix uses only one character chr(10).
    The new line character(s) may be OS-dependent.
    You could consider both with:
    replace(replace(column_name, CHR(13)||CHR(10), ' '),CHR(10),' ')
    Hartmut
    Edited by: hartmutm on 11.09.2008 01:32

  • New-line character in stacked message pop-up

    I have run into a brick wall with this situation--
    Our clients are running Client/Server Forms 6i, and Web Forms 6i using Patch 10. They are about to upgrade web forms to the latest version 9.0.4.1.0 (10g).
    We have a few PLL routines that use the stacked message method:    Message('text here'); Message('  ',no_acknowledge);to display important error messages to the user. It is especially useful to display the multiple ORA- errors when an unexpected server error occurs.
    Throughout all versions of Client/Server forms, and even in our old version of Web forms, I can use chr(10) or another character to start each error message on a new line.
    Somewhere after Patch 10, Oracle has removed that capability. Instead, pop-up stacked messages word-wrap into a multi-line message, and display the new-line character as a box indicating an unprintable character. Our nicely formatted messages are a mess!
    I have been told I should use an alert, which supports chr(10) as the new line. However, this is a PLL routine, and I would have to create an alert in hundreds of forms just to accommodate this short-sightedness. The changes and subsequent testing and release issues make this an unworkable solution.
    I am clueless as to why this feature would be removed. Oracle support is treating it as an enhancement request. Any ideas?

    Steve,
    If you really have hundreeds of forms ... create one more - to display your messages. Make it modal and nice looking. Call it through the library. Design it to work both as [OK] message and as an users responce [Yes]/[No]/[Cancel].
    And honestly - I don't think message(); message() is the best way to display messages. Whoever designed the application should've think about alerts with standartized naming convention, so they can be handled easily through the PLL.
    Venko

  • NEW LINE CHARACTER

    i am trying to load text into the BASIC TEXT of the material. The input file has matnr and the text. The file we loaded is fine. But in the text editor the # for new line character appears and this is causing problem while writing the text in a sapscript.
    so i am trying to remove the # for the new line character while we load the file. i am using
    data: c_tab like CL_ABAP_CHAR_UTILITIES=>CR_LF. to split the file and it is not being recognized. The input file is a tab delimited text file from excel. and it has " at the begining and ending.
    thanks in advance

    that is problem with Xls , If u have text with any Delimitors then u will get this kind of Stuff.
    prabhu,peram then i will get in text file as "prabhu,peram".
    Regards
    Prabhu

  • Regexp_substr to exclude new line character

    I have a varchar2 field that stores new line character at the end of the char string . How do I extract just the char string and not the new line character using regexp_substr ?
    Thanks
    Billu

    Hi,
    Assuming the newline character is CHR (10),
    RTRIM (string, CHR (10))returns a copy of string with the newline (if any) removed from the end. This is more efficeint that regular expressions.
    If you really want to use regular expressions anyway, REGEXP_REPLACE is sometimes easier to use than REGEXP_SUBSTR.
    REGEXP_REPLACE ( string
                , CHR (10) || '*$'
                )does the same thing as the RTRIM expression above. Omit the * if you want to remove only 1 newline from the end.
    Edited by: Frank Kulash on Feb 9, 2010 4:37 PM

  • New line character and carriage return in XML, please help, thanks

    In XML, "&#10;" is only the new line character. I have tried that. If you put that in your XML, for example:
    <tag>line1&#10;line2&#10;line3</tag>
    You will get the output as follow:
    line1
    ____line2
    ________line3
    (where ___ represents space)
    The output that I want is actually like:
    line1
    line2
    line3
    So I would like to ask how I can do this.
    Thanks,
    Jackie

    while parsing your XML file you can directly suppress these newline and similar things in characters() method of SAX parser.
    you can opt to do nothing when you encounter them else if it is normal character then use it to print it.

  • Problem with CDATA and new line character

    I parse a xml document with org.w3c.dom, the document contain a CDATA section in which there are more lines of text, each line is terminated with the new line character (\n).
    Example:
    <nota>
    <[CDATA[
    first line
    second line
    third line
    ]]>
    </nota>
    When a parse this node:
    Text txt_nota=(Text)elm_nota.getFirstChild();
    String nota=txt_nota.getData();
    the value returned is one string with no new line characters, example:
    "first linesecond linethird line"
    what's wrong?

    Because i use the string nota into a jsp page and i print the string nota into a textarea and the text is with no newline, example:
    <textarea name="nota" rows="4" cols="60"><%= nota %></textarea>
    the text into textarea is:
    first linesecond linethird line
    but i want that the text displayed into textarea is equal the text into the CDATA section:
    first line
    second line
    third line

  • Need help in how to print new line character in unix using java

    Hi All,
    I use the printstream class to print some line in a text using java.
    here is the code:
       FileOutputStream out; // declare a file output object
            PrintStream p; // declare a print stream object
                    p.print("\t");
                    p.print(date);
                    p.print("\t\t");
                    p.print(RecCount);
                    p.println("\n");when i use this and output of this character in windows is
    date RecCount
    22-07-2007 23456
    when i use the same code in unix it shows the following output:
    date RecCount[]22-07-2007
    it wont accept the new line character could any one give me an idea to solve this problem.

    PrintStream has a println() method. Use that. Or System.getProperty("line.separator").
    Because a newline char doesn't necessarily specify a line break. It's system-dependent.

  • New Line character in BO DS

    Hi Experts,
    Can you please help me in telling the new line character in Data Services, so that I can use that in script.
    I tried using \n for new line, but of no use.
    Regards,
    vivek

    Hi Shine SS,
    Had same requirement and your solution worked.
    Thanks.

  • New-line Character for a file opened in BINARY mode for O/P

    Can anybody please tell me how to put a new-line charcter for each record in a file opened in Binary mode for O/p. I cant use text mode  for other reasons in my scenario.
    DATA: l_outdata TYPE xstring.
    OPEN DATASET file FOR OUTPUT IN BINARY MODE.
    Application logic to populate l_outdata
    TRANSFER l_outdata TO file.
    Any help, or attempt towards it will be duely rewarded,
    Thanks in advance,
    Sujit.

    hi sujit,
    1. how to put a new-line charcter for each record
    but how will you decide, at which POSITION,
    to put the new line character, if u have opened the file in binary  mode.
    2. However, if u know the exact positions(s),
      u can use  CL_ABAP_CHAR_UTILITIES=>CR_LF
      to insert the new line character,
    regards,
    amit m.

  • Problem with new-line-character and java.io.LineNumberReader under AIX

    Hi folks,
    I got the following problem: I wrote a little parser that reads in a plain-text, tabulator-separated, line-formatted logfile (and later on safes the data to a 2-dimensional Vector). This logfile was originally generated by an AIX ksh script, however, I copied it on my Windows machine to work with it (for I'm using a Java editor that runs under Win Systems).
    For any reason, Windows, and what is worse Java too, seems not to recognize correctly the new-line character (in the API it is written that this should be a newline '\n' or a carriage-return '\r' or one followed by the other) that marks the end of a line in the logfile.
    Also, when I'm opening the logfile with the "Notepad"-editor, this special character does not seem to be recognized, every line is inserted right after the other.
    On the other side, when I open the logfile with the built-in editor in the CMD-Shell ("Dos-shell"), the newline chars seem to be recognized correctly.
    But when start my parser on the AIX-machine the newline does not seem to be recognized correctly again.
    I tried to read in the logfile with MS-Excel and safe it as a plain-text, tabulator-separated, line-formatted logfile again, with such files my parser works fine both on the AIX as it does on Windows.
    Any ideas? Anybody got over the same problem already?
    Greetz FK

    Under windows, text files' lines are usually delimited by \r\n,
    under Unix/Linux/AIX etc. \n
    and under Mac \r.
    I recommend to use the following editors, which are capable to handle files with Unix and Windows-styled line-delimiters or convert between these types:
    Programmer's File Editor (PFE; available on Windows)
    The Nirvana Editor (http://www.nedit.org/; available on Unix, MAcOS, Windows)
    (BTW good old vim can handle that too. Transferring text files to windows in order to edit them, even using Excel for this purpose means your being a UNIX newbie, (I mean no offense by writing this) so vim is probably beyond your reach for the moment.)
    Java normally assumes the platform's line delimiters where it is running, so if you transferred the file from Unix to Windows might be distrurbing.

  • Replacing New Line character in a hexadecimal string in ECC5.0

    Hi,
    I am trying to create an XML document using ABAP.
    I have created one DOM and later used the DOM to get the XML content into an internal table in form of Hexadecimal String. In that internal table(which contains XML in form of hexadecimal content), I want to search for the new line character and replace it by Space.
    I have used class CL_XML_DOCUMENT to create such document.
    Now, the keyword 'SEARCH' which searches the New Line character, works on the hexadecimal content of the internal table in 46C and I get an XML document. I get the position of the New Line in SY-FDPOS and can do whatever I want. But SEARCH on hexadecimal content is not permitted in ECC 5.0. I get a syntax error when I try to do so. Tried many options but could not succed.
    Would apreciate if anyone can help in finding and replacing characters like new line, tab etc in a hexadecimal string.
    Thanks.
    Can anyone

    Hi!
    When you say hexadecimal string, you mean variable - otherwise string (= character) operations would work?
    Then you have to go for hex handling -> do it yourself. Make something like
    data: lf type x value '0A',
          sp type x value '20',
          i type i.
    I = 0.
    while sy-subrc = 0.
      if hex_string+i(1) = lf.
        hex_string+i(1) = sp.
      endif.
      add 1 to i.
    endwhile.
    Regards,
    Christian

  • How to insert a new line character inside CDATA tag in the source xml data file?

    values for form fields in the xml data file is contained inside CDATA tags which is an Unparsed Format.
    Eg: [CDATA[IBM-01 ~ DSHFSJDSJ ~ FGFGFJ, ~ VA 665665]] delimited by "~" char
    Actual o/p:-
    IBM-01 ~ DSHFSJDSJ ~ FGFGFJ, ~ VA 665665
    Expected o/p is like :-
    IBM-01
    DSHFSJDSJ
    FGFGFJ,
    VA 665665
    live cycle product does not interpret ~ as a newline character. Please suggest which character should be used instead inside CDATA section or if there is any other way to fix this?

    I do not have any problem while using IE's XML parser
    for XML+XSLT merging.That is because IE's parser does not implement XML correctly.
    But when I use JAXP's Transformer object, it does not
    preserve the new lines inside attribute values and
    converts those into white spaces.That is exactly what the XML specifications say should happen.
    >
    ----If you have text that contains newlines, you
    should put it in an element, not in
    ----an attribute.
    That would be my last solution. But I'd really hate
    to change my logic just 'coz JAXP is not capable of
    handling new lines inside attribute values. I may be
    wrong... but If IE can keep those then there has to
    be a way to do the same from server side merging....Sure. Write your own parser with the same bug in it. But you don't have any right to demand that other people supply you with parsers that work incorrectly.

  • New line character in File adapter

    I am having a receiver file adapter which generates files with multiple lines.
    My problem is when the target file is opened in notepad there is no line break and the lines comes as continous string with small rectangle as separator.This fails the target upload program.
    When I remove those small squares in notepad and hit enter and then upload it gets uploaded successfully.
    Is there any way to have line break so that new line will be generated each time (the documenation says the by-default it adds new line character then why in notepad it opens like a continous string?)
    Thanks in advance.
    Regards
    Rajeev

    Hello
    I know by default File Adapter value is line break. But if I open that generated file in notepad, the record does'nt appear on the new line. Instead at the end of each line there is special character added at the end of each record. When I hit enter and deletes that special character and then try to load that file it gets loaded successfully.
    So my problem is how to generate the file will give record on the new line. I tried to give 'nl' as endSeparator.
    How to give hexadecimal values? I tried giving '0xHH' but that gives error in File Adapter
    "Error: Conversion initialization failed: Exception: java.lang.NumberFormatException: For input string: "HH"
    Thanks in advance.
    Regards
    Rajeev

Maybe you are looking for