Hi,
Can someone tell me how to identify a carriage return character in string

Recommended Answers

All 5 Replies

Just like you would identify any other character in a string: look for "\r\n" or "\n" (system dependent).

I believe there's a static variable or system propery that holds the proper return character for the system the vm is running on. Sorry I can't remember exactly what it was.

Yes, System.getProperty("line.separator") can be used for the system you are running on, but if you are reading files from external sources the linefeeds may differ from your own.

You people are getting confused between newline and carriage returns. A carriage return is just a carriage return and is always '\r'.

It's the 'newline' character which is different on different systems. (\r, \n, \r\n)

You people are getting confused between newline and carriage returns. A carriage return is just a carriage return and is always '\r'.

It's the 'newline' character which is different on different systems. (\r, \n, \r\n)

Yes, agreed. I just figured he was asking in a more general sense about line breaking characters.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.