aspose file tools*
The moose likes I/O and Streams and the fly likes need to ^M at end of file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "need to ^M at end of file" Watch "need to ^M at end of file" New topic
Author

need to ^M at end of file

Shardul Vyawahare
Greenhorn

Joined: Dec 30, 2010
Posts: 8
Hi All,

I am not familiar with Unix. I am creating a text file through the my Java code. Now my client want me to add ^M character at end of file so he will identify end of file in Unix env. How to add ^M in file is it any escape seq char . does he mean to add "\r\n" at the end ?

Please help.

SH
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3649
    
  17

^M is just carriage return, so the Java equivalent would be '\r'.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2864
    
  11

The normal UNIX/Linux/Max OSX line separator in just "\n". It's Windows that uses "\r\n", so your client might not have that right. Also, it's a line separator, not a file ender. There's no file ending character in UNIX. DOS used to use ^Z, but I haven't seen that in a long time.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3649
    
  17

I was thinking that maybe the fact that carriage return is not used in UNIX would allow it to be a custom file ending character for the client's file format?
 
jQuery in Action, 2nd edition
 
subject: need to ^M at end of file