Posted: Sat Jun 14, 2008 1:04 am Post subject: RE:File Reader!- Help!!
It does not include the line break characters. It skips over those and simply returns the value of the line as you would see it in Notepad, for example.
The buffer.read() method returns the ascii value (assumed ascii encoded file) of the next character. So if you called it first, it would report 51, the ascii value of "3".
Sponsor Sponsor
Shivu
Posted: Sat Jun 14, 2008 1:06 am Post subject: RE:File Reader!- Help!!
if it does not read the break characters, how does it go to the next line?...
but the break characters are always present ?
i ask too many questions... sry
thanks!!
Euphoracle
Posted: Sat Jun 14, 2008 1:24 am Post subject: RE:File Reader!- Help!!
- It skips the break characters, but still situates the position after the break characters.
- Without break characters, there's no line break. The exception is the EOF, which is read as a single line from the last break character.
Zeroth
Posted: Sat Jun 14, 2008 8:42 am Post subject: Re: File Reader!- Help!!
It does NOT include the \r\n. (Note the order of the two characters. That is important.) Then it moves onto the next line.
Here's an example that might help:
say you're building a telnet application. In telnet, all enters are translated into \r\n.
Treat the incoming connections like just a file, and use Bufferedreader on them. It will keep trying to read from the connection until it gets the pair \r\n, then it returns all the data its grabbed.
Now, to turn an ascii into to a char... have you been taught about casting yet?
Here's the solution:
code:
int i = 65;
char ch = (char)i;
ch='A'
I want you to look at that, and think about what is happening. Its taking the int value... and what? is the char value any different? Or, maybe its the context that is different(for the program)? The idea here is that you will understand more than just solving this one problem, but look at what you've learned, and be able to apply to harder ones.