I am creating a file for a rigid system that doesn't like \r\n at the end of the file. But while creating the file, java adds it automatically.
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
public class FileTest {
    public static void main(String[] args) throws Exception {
        String fileText = "a\r\nb";
        String filePath = "/log/engines/Testfile.txt";
        FileOutputStream out = null;
        ByteArrayOutputStream byteOut = null;
        try {
            out = new FileOutputStream( filePath);
            byteOut = new ByteArrayOutputStream();
            char[] charArr = fileText.toCharArray();
            for( int i=0; i<charArr.length; i++) {
                byteOut.write( charArr[i]);
//              out.write( charArr[i]);
            }
            byteOut.writeTo( out);
            System.out.println( "Last Char in File =" +charArr[charArr.length-1] +"=" +(int)charArr[charArr.length-1]);
        } finally {
            if (byteOut != null) {
                byteOut.close();
            }
            if (out != null) {
                out.close();
            }
        }           
    }
}
The binary of this file is as below -
610d 0a62 0d0a == (a\r \nb \r\n)
0d = "\r"
0a = "\n"
I am fine with the first "\r\n" which I am adding, but not the last one that gets added by itself. Appreciate any help.
