jQuery in Action, 3rd edition
The moose likes I/O and Streams and the fly likes File Reader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "File Reader" Watch "File Reader" New topic

File Reader

Gerhard Abrahams

Joined: Dec 04, 2003
Posts: 15
I managed to get the stuff from my TextArea into a text file now I would like to open the same file using the FileReader and load it into the TextArea.
Yet when I try I get a compilation error. Incompatible types.
The complete code is below and it happens in the Open class
What is it I am doing wrong again?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

String inhalt;
while ((inhalt = einlesen.read())

"read" returns int (not char, so that it can hold either a character or -1 to indicate EOF.) Trying to assign this int to "inhalt", which is a String, gives the incompatible type error.
There are a number of ways to do this; probably what you want to do is use something like

This reads in a chunk of characters at a time rather than just one, so it's far more efficient.

[Jess in Action][AskingGoodQuestions]
Gerhard Abrahams

Joined: Dec 04, 2003
Posts: 15
That looks very good to me gives me some ideas for the sorting algorithm too. I keep on trying. Thank you for your quick reply
I agree. Here's the link: http://aspose.com/file-tools
subject: File Reader
It's not a secret anymore!