Reputation: 5655
I am trying to understand few java file concepts. So I tried with below program to understand FileOutputStream
FileOutputStream out = new FileOutputStream("test.txt");
int i = 1;
out.write(i);
out.flush();
out.close();
Some binary data has been writen in the file.
But the for the same program when I change the value of i
from 1 to 10. I don't see anything in my output file. Can someone explain me why with some internal details.
Upvotes: 0
Views: 96
Reputation: 311048
int i = 1;
out.write(i);
That writes 0x1
to the file.
out.flush();
out.close();
The flush()
is redundant.
Some binary data has been writen in the file.
Correct.
But the for the same program when I change the value of i from 1 to 10. I don't see anything in my output file.
Yes you do. You see 0xa
, which is a line feed character.
Upvotes: 1