-4

I am reading different files from different operating systems. In file there are lots of lines. but i got info that after every line there may be use "\n" or "\r" or something like that. When i read file by following instructions from Best way to read a text file [closed]

then what should i add to print in console by if-else conditions which explain in Class Pattern. I need help please. I am trying by reading this. But still need experts help. Thanks.

Community
  • 1
  • 1
Mandar Khire
  • 49
  • 2
  • 10
  • Can you mention what you tried for this.. – Janny Mar 27 '13 at 06:20
  • -1. Can't understand your english at all. I have no clue what you are trying to do or why these three things you have linked are relevant. – Sanchit Mar 27 '13 at 06:22
  • I have one file! I am trying to read & write it in to few lines but before writing basic way i want to try to find out how one line ends in that file! How blank space use in it. If my new lines not match that pattern then it will give me error in future. – Mandar Khire Mar 27 '13 at 20:19

1 Answers1

0

If you're just printing to the console, you can simply use \n. To give you a little background, the times where those two separators really matter is within the files themselves (and when you must manually detect or write newlines in a file). In a unix-based system, newlines are represented in files by \n. In Windows, newlines are represented by \r\n. But when you are printing to the console, \n will perform correctly.

Also in the pattern matching example you gave. You're simply manually adding a newline so you can tell where a newline is. So especially in that case, you can mark the newline however you want as long as it's consistent.

Memento Mori
  • 3,327
  • 2
  • 22
  • 29
  • I have file which generated by some application when i open it in notepad in windows or linux then i not understand in this file any characters(\n or \r\n or something else) used or not. I am trying to write program which read file & give me info which character use & where? Any help? – Mandar Khire Mar 27 '13 at 06:51