Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #39780

Re: Handle delimiter in read message

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Handle delimiter in read message
Date 2022-05-23 10:33 -0400
Organization A noiseless patient Spider
Message-ID <t6g608$hha$1@dont-email.me> (permalink)
References <43d5ea21-6264-4b24-ab0c-32c27cdc09c2n@googlegroups.com> <08d72ee6-dd98-46ab-a0b8-ae683996b3d8n@googlegroups.com> <71e3ac9a-032a-42d5-b509-884e36908b81n@googlegroups.com> <2353f4c2-b2a5-4036-9a7f-8be371b9c446n@googlegroups.com> <4ceef2dc-8924-4ab2-b400-73066308a83cn@googlegroups.com>

Show all headers | View raw


On 5/23/2022 9:31 AM, e.d.pro...@gmail.com wrote:
>> I found out I can do:
>>
>> String endofMsg = sb.toString().substring(sb.toString().length() - 6);
>> return endofMsg.matches("\\r\\n##\\r\\n|.*\\n##\\n$");
>>
>> I had to use the last 6 characters since newline is different for each platform.
>>
>> //mike
> 
> I'm not clear what is the problem you're trying to solve, but System.getProperty("line.separator") is system dependent, so if you're running that on one system to get a value to use on a different system, your value will be wrong if the systems are different. *nix uses \n for linefeed, Windows uses \r\n , so you're checking for the presence of \n if you want to check for a linefeed.

     Also (if I recall correctly), various Internet RFC's require CR-LF
line terminators, regardless of the system sending the lines.  I don't
know whether mike's messages follow such a protocol, but many do.

     His best bet may be to recognize all of CR, LF, and CR-LF as line
terminators, and maybe even LF-CR as well.

-- 
esosman@comcast-dot-net.invalid
Look on my code, ye Hackers, and guffaw!

-- 
This email has been checked for viruses by AVG.
https://www.avg.com

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Handle delimiter in read message mike <mikaelpetterson@hotmail.com> - 2022-05-22 23:09 -0700
  Re: Handle delimiter in read message mike <mikaelpetterson@hotmail.com> - 2022-05-23 02:31 -0700
    Re: Handle delimiter in read message mike <mikaelpetterson@hotmail.com> - 2022-05-23 02:59 -0700
      Re: Handle delimiter in read message mike <mikaelpetterson@hotmail.com> - 2022-05-23 04:34 -0700
        Re: Handle delimiter in read message "e.d.pro...@gmail.com" <e.d.programmer@gmail.com> - 2022-05-23 06:31 -0700
          Re: Handle delimiter in read message Eric Sosman <esosman@comcast-dot-net.invalid> - 2022-05-23 10:33 -0400
        Re: Handle delimiter in read message Arne Vajhøj <arne@vajhoej.dk> - 2022-05-23 11:21 -0400
    Re: Handle delimiter in read message Stanimir Stamenkov <s7an10@netscape.net> - 2022-06-07 23:19 +0300

csiph-web