Trying to capture line feed or carriage return

We have a socket application. We would like to know what is the line terminating character? Below is a snippet of codes. Any comments if this is right?
BufferedReader readerBuffer = null;
readerBuffer = new BufferedReader(new InputStreamReader(sockConn1.getInputStream()));
int readChar=0;        
while ((readChar=readerBuffer.read()) != -1)
     System.out.println("Read char "+(char) nextChar); 
}

Below is the full codes without the db connection and processing as we see that will be too long here.
public class deviceServer {
  class deviceConnectionHandler implements Runnable {
    private Socket sockConn1;
    deviceConnectionHandler(Socket receivedSocketConn1) {
      this.sockConn1=receivedSocketConn1;
     Connection dbConnection = null;
     Statement dbStmt = null;
     public void run() {
     String completeMessage="";
     BufferedReader readerBuffer = null;    
    BufferedWriter writeBuffer = null;
     try {
         readerBuffer = new BufferedReader(new InputStreamReader(sockConn1.getInputStream()));
         writeBuffer = new BufferedWriter(new OutputStreamWriter(sockConn1.getOutputStream()));
         int readChar=0;        
         sockConn1.setSoTimeout(120000);
       //dbConnection = connectionPool.getConnection();
         //dbConnection.setAutoCommit(false);
             while ((readChar=readerBuffer.read()) != -1)
                       System.out.println("Read Char : "+(char) readChar);
                       completeMessage += (char) readChar; 
                     if (readChar == '*') {
                     try {
                      writeBuffer.write("@@\r\n\r\n");
                     writeBuffer.flush();                    
                      //db processing
                       dbConnection.commit();
                    catch (SQLException ex){
                         ex.printStackTrace();
                            try{   
                                dbConnection.rollback(); 
                                catch (Exception rollback){   
                                     rollback.printStackTrace();
                     catch (Exception e){
                           e.printStackTrace(System.out);
                               try{   
                                dbConnection.rollback(); 
                                catch (Exception rollback){   
                                     rollback.printStackTrace(System.out);
                     finally{
                            try{
                                 if ( dbStmt != null ){
                                   dbStmt.close();
                            catch(SQLException ex){
                            ex.printStackTrace(System.out);
                   completeMessage="";          
           catch (SocketTimeoutException ex){
                ex.printStackTrace();
           catch (IOException ex){
                ex.printStackTrace();
           catch (Exception ex){
                ex.printStackTrace();
           finally{
             try{
                  if ( dbConnection != null ){
                    dbConnection.close();
             catch(SQLException ex){
                 ex.printStackTrace();
             try{
                 if ( writeBuffer != null ){
                         writeBuffer.close();
             catch(IOException ex){
                ex.printStackTrace(System.out);
   public static void main(String[] args) {
      new deviceServer();
   deviceServer() {
      /*try {
      // setup the connection pool
      catch (SQLException e) {
         e.printStackTrace(System.out);
      try{
            final ServerSocket serverSocketConn = new ServerSocket(7000);                    
            while (true){
               try{
                   Socket socketConn1 = serverSocketConn.accept();
                 new Thread(new deviceConnectionHandler(socketConn1)).start();                          
               catch(Exception e){
                  e.printStackTrace();
      catch (Exception e){
         e.printStackTrace();
}

Similar Messages

  • How do I add either a line Feed or Carriage Return to a column?

    I am using
    "Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production"
    "PL/SQL Release 11.2.0.1.0 - Production"
    "CORE 11.2.0.1.0 Production"
    "TNS for Linux: Version 11.2.0.1.0 - Production"
    "NLSRTL Version 11.2.0.1.0 - Production"
    I would like to know when merging two results like so:
    select
         'Answer: ' || answer_value || 'Date: ' || date || 'Name' || name_value as notes
    from table
    to show as in the column:
    Answer: B
    Date: 07-11-2013
    Name: Johnny
    I get something like this
    Answer: B Date: 07-11-2013 Name: Johnny
    Is there a way to use Line Feed or Carriage Return?
    I tried using the char(10) but did not work.
    Also where are the instruction to be able to place the query into a format to allow others to see? Originally I learned to use code { } on this site, but they changed it.
    example:
    select
    'Answer: ' || answer_value || 'Date: ' || date || 'Name' || name_value as notes
    Testing it above.
    Plus what happened to the preview button to see if I posted it correctly?
    The section on" how to ask a question "did not have much about this.

    You may be going about this the wrong way.  Such formatting is normally left to the reporting tool.
    Embedding formatting junk (like cr/lf) in your data is not a good idea.  Not only does it not belong there, but it might not always work.  CR and/or LF are platform specific.

  • JeditorPane text selection problem due to line feeds and carriage returns

    Hi folks,
    I have a jEditorPane (text/plain) that contains a document in which the user has highlighted some text. I want to pull the selected text from the pane, do some processing on it, and then put the altered text back in the same position.
    First I get the starting and ending position of the highlighted text
    int mySelStart = myJEditorPane.getSelectionStart();
    int mySelEnd = myJEditorPane.getSelectionEnd();Then I get all the text from the pane and (in theory) strip out the portion the user highlighted
    String myPaneText = myJEditorPane.getText();
    String mySelectedText = myPaneText.substring(mySelStart,mySelEnd);But the text string in mySelectedText never matches what the user originally highlighted. The starting and ending positions are off by the number of carriage returns that proceed the highlighted text in the document. It appears that while in the jEditorPane Java treats the carriage return as one characters, but once the info is in the myPaneText field Java treats the carriage return as two characters.
    Has anyone encountered this before? Am I doing something wrong? To fix the problem I'm looping through the entire document to find out how many carriage returns proceed the highlighted text, but there has to be an easier way.
    Thanks

    It appears that while in the jEditorPane Java treats the carriage return as one
    characters, but once the info is in the myPaneText field Java treats the carriage
    return as two characters.Correct on a Windows platform. Check out my posting here for a one line solution:
    http://forum.java.sun.com/thread.jspa?forumID=31&messageID=1464594

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

    In XML, "
" 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.

  • Carriage Return in External table column

    Im using Oracle 9.2.0.6 . On Aix.
    Ive created and external table pointing to a csv file.
    When I do a select on the last column of the external_table, it contains a carriage return / linefeed. If I try to make the colums specification smaller then it throws and error
    ORA-01401: inserted value too large for column
    How can I eliminate this unwanted character.
    line from csv file
    2,,,,,,,,,,,,,,BB
    table spec
    create table x_needsprop
    external_prop_ref varchar2(20),
    floor_level     varchar2(20),
    dcc     varchar2(4),
    lc     varchar2(4),
    ptd     varchar2(4),
    wc     varchar2(4),
    ec     varchar2(4),
    rspr     varchar2(4),
    err     varchar2(4),
    ctb     varchar2(4),
    bd     varchar2(4),
    nda     varchar2(4),
    ndd     varchar2(4),
    vsam     varchar2(4),
    res_type varchar2(5)
    ORGANIZATION EXTERNAL
    ( type oracle_loader
    default directory external_dir
    access parameters
    ( fields terminated by ',' )
    location ('needsprop.csv')
    /

    According to the documentation, adding the trim specifer 'RTRIM' directs that "spaces should be trimmed from the end of a text field. Spaces include blanks and other nonprinting characters such as tabs, line feeds, and carriage returns."
    create table x_needsprop
    external_prop_ref varchar2(20),
    floor_level varchar2(20),
    dcc varchar2(4),
    lc varchar2(4),
    ptd varchar2(4),
    wc varchar2(4),
    ec varchar2(4),
    rspr varchar2(4),
    err varchar2(4),
    ctb varchar2(4),
    bd varchar2(4),
    nda varchar2(4),
    ndd varchar2(4),
    vsam varchar2(4),
    res_type varchar2(5)
    ORGANIZATION EXTERNAL
    ( type oracle_loader
    default directory external_dir
    access parameters
    ( fields terminated by ',' RTRIM)
    location ('needsprop.csv')
    )

  • Read Only TextAreas with Carriage Return, Line Breaks and Word Wrapping

    Hi all,
    I know there are a few posts around this subject but I cannot find the answer to the exact problem I have.
    I have a page that has a 'TextArea with Character Counter' (4000 Chars) that is conditionally read only based on the users credentials (using the 'Read Only' attributes of the TextArea item).
    When the field is editable (not Read Only) everything works fine but when I make the field Read Only I start to have problems:
    The first problem is that the Carriage Return and Line Breaks are ignored and the text becomes one continuos block. I have managed to fix this by adding pre and post element text of pre and /pre tags. This has made the Carriage Return and Line Breaks word nicely and dispaly correctly.
    However, it has introduced a second problem. Long lines, with no Carriage Returns or Line Breaks, now extend to the far right of the page with no word wrapping, making my page potentially 4000+ characters wide.
    How can I get the field to be display only, with recognised Carriage Returns and Line Breaks, and Word Wrapping inside a fixed width of, say, 150 characters?
    Many thanks,
    Martin

    Hi,
    Just a cut and paste of yours with the field name changed:
    htp.p('<script>');
    htp.p('$x("P3_COMMENTS").readonly=true;');
    htp.p('</script>');I also have the following in the page HTML Header, could they be conflicting?
    <script type="text/javascript" language="JavaScript">
    function setReleaseToProd(wpTypeCode){
       //setReleaseToProd($v(this))
      var get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=set_release_to_prod',0);
      get.addParam('x01',wpTypeCode);
      gReturn = get.get();
      if(gReturn) {
         $s('P3_RELEASE_TO_PROD',gReturn);
      get = null;
    </script>I am a long way from knowing much about Javascript (this page code was written by someone else) so all help is much appreciated.
    Martin

  • Replace line feed with perl

    I'm trying to replace 'line feed & space' with a line feed:
    perl -pi -e 's/\n /\n/g' ~/Desktop/scrap
    With no luck. Any help?

    I'm guessing this is related to line endings. If the file has legacy mac line endings it will behave as a single line. Try running the following. If it reports 0, then you'll need to convert the line endings:
    <pre style="border: 1px solid #ddd; padding-left: .75ex; padding-top: .25em; padding-bottom: .25em; margin-top: .5em; margin-bottom: .5em; margin-left: 1ex; max-width: 25ex; overflow: auto; font-size: 10px; font-family: Monaco, 'Courier New', Courier, monospace; color: #444; background: #eee; line-height: normal">wc -l < ~/Desktop/scrap</pre>
    The following will convert old mac line endings (as well as windows) to unix:
    <pre style="border: 1px solid #ddd; padding-left: .75ex; padding-top: .25em; padding-bottom: .25em; margin-top: .5em; margin-bottom: .5em; margin-left: 1ex; max-width: 40ex; overflow: auto; font-size: 10px; font-family: Monaco, 'Courier New', Courier, monospace; color: #444; background: #eee; line-height: normal">perl -pi -e 's/\r\n?/\n/g' ~/Desktop/scrap</pre>

  • Removing Carriage Returns within a Textarea

    Hi,
    Just wondering if someone could please let me know how to remove carriage returns from a Textarea after submitting the page?
    Within my PL/SQL process, I have used both REPLACE and TRANSLATE on both CHR(10) and CHR(13) but unfortunately it stills comes out the other end as follows:
    Description :this
    is
    a
    testWould like it all on one line minus the carriage returns.
    Thanks.
    Tony.

    The code I showed works for me. Computations and processes work similarly except that in a process you have to save the value in session state whereas in a computation that's done for you. Show your code or put an example on apex.oracle.com if you can't get it to work and I'll check it.
    Scott

  • Convergence and Comm Express missing carriage returns

    We have just upgraded our mail sever. We upgraded from Comm suite 5 (mail server 6.3.) on a sparc system to Comm suite 6 update 1 (mail server 7.0 update 1) . We have run into problems with alerts coming from our ERP (Oracle 11.5.9). These alerts are showing as one long line without any carriage returns in UWC and Convergence. The emails look fine in Outlook.
    Thanks for any help.
    Josh

    Coolhands_99 wrote:
    We have just upgraded our mail sever. We upgraded from Comm suite 5 (mail server 6.3.) on a sparc system to Comm suite 6 update 1 (mail server 7.0 update 1) . We have run into problems with alerts coming from our ERP (Oracle 11.5.9).
    These alerts are showing as one long line without any carriage returns in UWC and Convergence. The emails look fine in Outlook. I know of at least one bug (#6540158 - "javascript error if mailto: link contains encoded newline characters") that was fixed in recent MS6.3 patches and MS7.0 that may be impacting the display of Oracle ERP sourced emails -- it was the display of Oracle ERP source emails that caused the bug to be raised in the first place.
    That being said the Oracle ERP emails also had formatting problems which was fixed at the Oracle end.
    Please provide a sample of one of the problem emails (the raw *.msg output) that is causing the problem.
    Regards,
    Shane.

  • What is escape character for for Carriage Return, Line Feed, Form Feed

    Hi
    I need to a text file which should have following characters
    Carriage Return, Line Feed, Form Feed
    How do i insert them in a string
    i know "\f" is carriage return,
    but what are characters for line feed and form feed
    Ashish

    uncle_alice wrote:
    jverd wrote:
    remus.dragos wrote:
    I forgot that it does not exist in Java. A good thing
    from my point of view.Running the following makes my computer beep.
    public class Bell {
    public static void main(String... args) {
    System.out.println("\u0007");
    Sure, sending a BEL character to the console rings the bell, but that has nothing to do with Java. Anyway, I think he meant Java doesn't support the \a escape sequence in string and char literals.
    >
    >
    >I forgot that it does not exist in Java. A good thing
    from my point of view.
    Running the following makes my computer beep.
    public class Bell {
    public static void main(String... args) {
    System.out.println("\u0007");
    } Sure, sending a BEL character to the console rings the bell, but that has nothing to do with Java. Anyway, I think he meant Java doesn't support the \a escape sequence in string and char literals.
    Ah, I thought he was saying Java doesn't support ringing the bell.

  • Problem with "carriage Return" or "Line Feed" in a table

    Hello,
    I need help with the function Zeichen(), so called it in german, I'm not sure if it is char() in english.
    In Pages Version 4.0.1 (746) I've created a table in Pages with this function to make an "carriage Return" in a cell.
    Here an example: { ="Hello" & Zeichen(10) & "World" }, in the cell is now:
    | Hello |
    | World |
    But in Pages Version 4.0.3 (766) this function ZEICHEN() not allow the number 10 and other till 32 (I allready read the manual and understand this problem).
    Anybody an idea to make a "Carriage Return" or "Line feed" in a formular, in a cell, in a table, in Pages?
    Thanks
    Detlev Kormann

    kdetlev wrote:
    Your workaround will not be possible in my table, because there is no empty cell in the table, but I think it is also a good help too.
    *In fact I forgot that you are using a table in Pages.*
    Remaining on my first idea, In Numbers we may achieve the same goal using an auxiliary table with a single cell containing the needed line break.
    If this table is named "LineBreak",
    the formula will be:
    ="Hello"&LineBreak :: $A$1&"World"
    *In Pages, here is my workaround:*
    Enter the cell
    type a§b
    don't type the character § but ctrl + return.
    The cell will contain
    a
    b
    with the arrow, move before the a
    type =B2&"
    delete the original a
    move to the right
    delete the original b
    type "&C7
    Yvan KOENIG (VALLAURIS, France) mercredi 7 octobre 2009 17:20:04

  • How do we remove Carriage Return (line feed) inserted in FCC files

    Hi Experts,
    The file that we generate has a carriage return at the end.
    Is there any way in which we can remove this carriage return (line feed) from the file?
    The FCC parameters used at our end are as below:
    structure.filedNames:
    structure.fieldFixedLengths:
    structure.fixedLengthTooShortHandling: Cut
    Kindly tell us a solution ASAP.
    Thanks & Regards
    Dhwani

    Dear All,
    Let me elaborate on my query
    Consider that the files output looks like below:
    12  34  45  545 5454 UL
    23  33  43  434 4545 FG
    45  44  44  586 6535 GM
    Now there is an extra line(Carriage Return) getting inserted after the last line 45  44  44  586 6535 GM  which is not required at our end.
    The cursor of the file instead of stopping on the last character M, points to the next line.
    Can you please suggest how to remove this extra line from the files.
    I dont understan how will remove context help in this case.
    Regards
    Dhwani

  • How to find a carriage return and Line feed?

    I need to detect if a crriage retunr and line feed present on each row in my text file before allowing user to upload the text file
    I know how to remove them from each line but what I need is to detect them no removing them from file.
    Our concern is when the a row does not have carriage return and line feed.
    Is there a way to find this using CF? Please help
    thanks

    That is exactly the problem Dave, if some rows do not have line feed, they're not being inserted into DB, it skips other steps and go right to finish. It looks
    like the file is done processing.
    So I need to do early rejection to this kind of file.
    I used cfloop to catch anything else that do not follow the formatting rules.
    Here is what I already done:
    Right after the file got uploaded, I have these codes:   
    <cfloop  index="x" file="#MyFile#" >
      <CFSETMyLine = Replace(x,chr(9),"|", "ALL")>
      I'm using a few functions, such as, Left(), Mid(), Right(), etc to make sure certain rules are followed.
      Up till here, it's done and tested, everything is working.
      The only problem is when 1 or more rows don't end up with line feed and or carriage return.
      I plan to add some codes to check the end of each row for chr(10) since it is looping for every row anyway.
      If detected, process file normally otherwise stop processing.
    </cfloop>
    So this can't be done in CF?

  • XI: Remove Carriage Return +Line Feed at end of XML

    Hi All,
    Scenario
    Currently, we have a JMS --> XI --> IDOC scenario. The Sender Service always sends a CRLF (Carriage Return & Line Feed+) without fail at the end of each xml file once this non-sap system finishes its transaction.
    Example
    <STARTOFXML>
    Data------
    </ENDOFXML>CR+LF
    Question
    Is it possible to remove this from XI JMS Sender Adapter? From the receiver Service (JMS) this is possible.
    Cheers!
    Sulaiman

    Why do you want to remove this? Does this lead to errors?
    Regards
    Stefan

  • Carriage Returns, Line Feeds, and Tabs in Text Area

    I am having users copy and paste data from an Excel spreadsheet into a textarea on a BSP page.  When they submit this, since there are tabs and line feeds in the data, the BSP does not recognize the data.  The value in the field comes through as blank. When I manually type something into this field, with out any carriage returns, tabs, etc., the value does not come through as blank?  Does anybody know how to get around this?

    HI
    Iam uploading the data from application server(AL11) to other server.
    In the GLPCA-SGTXT(Table) iam having some text like 'This is good ##'.i was downloded some other data with this text('This is good ##') by using report program in to aplicationserver(AL11) and from there iam uploading that data into other server.
    But here the problem is in the UNIX, it was showing some problem.
    That is actually it need to show the format like:
    001 256 786 This is good## 459786
    But here it was showing like:
    001 256 786 This is good^M
    459786
    So here '459786' is coming to next line. But i need this '459786' also in the same line.
    I am not sure if it is possible to remove CR and LF's using the code the program is written in, but that is what we need to do.   In Unix  ^M is the CR (Carriage return), but I am not sure what LF is?

Maybe you are looking for