Just for getting a better understanding of what I've heard in a lecture (about Java Input- and Output-Stream) I've made myself this tiny program:
public static void main (String[] args) throws Exception {
int input;
FileOutputStream fos = new FileOutputStream("test.txt");
// 95 is the underscore-char ( _ ). I use it
// for to finish it reception of input.
while ((input = System.in.read()) != 95) {
fos.write(input);
out.println(input);
}
out.println("- Finished -");
fos.close();
}
It prints the numerical representation of the character I've just typed to stdout. It works basically but here is what I see in Eclipse:
"10" is the decimal ASCII representation of the line feed.
Okay. I've pressed the enter-key for to finish the iteration.
But why does this second value appear too?
I would expect only the first key (the actual character) to appear.
If somehow can explain the issue then I would appreciate his / her answer.
@Sanket Makani Here's the corresponding content of the text-file "text.txt":
2
3
A
a
In Eclipse: