thanks for your reply. But i don't understand one line in your reply. Whad do you mean by this?---just an enter in "info.txt" would represent '\n' in the file.
and in java api of PrintStream class its written--a PrintStream can be created so as to flush automatically; this means that the flush method is automatically invoked after a byte array is written, one of the println methods is invoked, or a newline character or byte ('\n') is written.
In first case, we are invoking write() method with '6' , not with '\n'. Then why this o/p?
and in second case, just by presing enter, how the flush() gets invoked? Its clearly written in API, autoflush should be enabled, and one of the above conditions should be met, then only, it gets written.