File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

File Reader

Gerhard Abrahams
Greenhorn

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
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34


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
Greenhorn

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
 
Similar Threads
Action Listener
AWT
Calculator problem
help please?
basic things with awt