[SOLVED]
Seems like my application isn't the problem. Reading char by char as suggested doesn't show any CR. The error is probably on the receiver side (independent of my application) which, for whatever reason, adds a 0x0D char. Still this can be a good example of how to put \n only.
[/SOLVED]
I have a strange behavior in my application:
I need to end each line with a LF only which should be "\n" as far as I know. Still I'm getting CRLF for every line (as if I was writing "\r\n").
The application is quite complex so I'm pasting here a sample code
private static final String STR1 = "Str_1";
private static final String STR2 = "Str_2";
private static final char NEW_LINE = (char)0x0A;
//private static final String NEW_LINE = "\n";
public static void main(String[] args) {
//They all return CR+LF instead of LF only.
System.out.println("Str_1\nStr_2");
System.out.print(STR1+NEW_LINE+STR2);
try{
FileOutputStream fos = new FileOutputStream("tests\\newline_test.txt");
fos.write((STR1+NEW_LINE+STR2).getBytes()); //The case I'm mostly interested into
fos.close();
} catch (IOException e){
e.printStackTrace();
}
}
I'm using Eclipse with Java6 (forced) on Windows platform (forced).
Is there any setting that could be messing up with this? Or am I missing something?