reading the contents of a file using readLine()
Hi everyone,
I am reading from a file using the readLine() method and assigning the value to a String. Now using readLine() i can read only a single line in the document. My file consists of several lines. how do i read from all the lines and assign it to a String? Please help.
{
File f =new File("mydata.txt");
FileInputStream fis =new FileInputStream(f);
BufferedInputStream bis =new BufferedInputStream(fis);
dis =new BufferedReader(new InputStreamReader(bis));
fileText = dis.readLine();
System.out.println(fileText);
}
Thanks
[845 byte] By [
u4unnia] at [2007-10-2 7:36:00]

> hi ,
> It was fine we can read the line with the help of
> of the above code.What about when we want to display
> it on the device screen.
> Do we need seperate coding for implementing the
> the alignment or seperate method was available
>Lakshman
Hi Laksman,
I'm sorry, but don't understand what you mean by that.
kari-matti
hi kari,
i meant, that the entire text will be display in a single line.ie see the following line
the line will be displayed as such,without any border to go to the next line
but we want
The line will be displayed
as such, without any
border to go to the
Next line
can you feel the difference ,
Lakshman
hi kari,
i Like your idea,but when the length of the screen was changed then we find odd with the text display.
At the same time we should consider the Scrolling option(When the text was too large to diaply in a single screen).
I hope that we have to write an seperate method manually to align the text.Because i have not found any method to do the alignment
Lakshman
> I hope that we have to write an seperate method
> thod manually to align the text.Because i have not
> found any method to do the alignment
hi,
I think so too. You'll have to count the number of letters that fit on screen, and parse the String by that.
kari-matti
hi kari,
I hav ewriten the code which will display the string line by line by calculating the string width and also considering the follwowing factors
1.Which Font we are using
2.calculating the width and height of the display screen
3.width of the letter and whether it will will fit in the remaining place
And with the points in mind i written the code
Thanks for your suggestions
lakshman