Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » FileReader() constructor issue in Eclipse??
FileReader() constructor issue in Eclipse?? [message #210374] Fri, 11 May 2007 12:29 Go to next message
Eclipse UserFriend
Originally posted by: stedav.stevedavies.gmail.com

Hi,

I'm trying to create a basic File io reader to read from a text file in
Eclipse. I start with the usual try/catch block for IOExceptions. here
is an example of my code:

FileReader fr = new FileReader("lorum.txt") //a simple txt file I have



However in Eclipse at this stage I get a red underline error saying
"the constructor FileReader(String) is undefined."

I have tried also creating a new File Object (File myFile = new
File("lorum.txt"); and then chaining it to a FileReader but still I have
no success. In the Java API it says FileReader class takes a String
constructor argument (String) which is what I have tried in the first
sense "lorum.txt"

Is this an issue with my Code or a problem n Eclipse??


Stedav
Re: FileReader() constructor issue in Eclipse?? [message #210424 is a reply to message #210374] Fri, 11 May 2007 14:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse5.rizzoweb.com

Steve Davies wrote:
> Hi,
>
> I'm trying to create a basic File io reader to read from a text file in
> Eclipse. I start with the usual try/catch block for IOExceptions. here
> is an example of my code:
>
> FileReader fr = new FileReader("lorum.txt") //a simple txt file I have
>
> However in Eclipse at this stage I get a red underline error saying
> "the constructor FileReader(String) is undefined."

Check the import statement and make sure that the FileReader you are
using is actually java.io.FileReader and not some other class in a
different package.

Hope this helps,
Eric
Re: FileReader() constructor issue in Eclipse?? [message #210440 is a reply to message #210424] Fri, 11 May 2007 14:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stedav.stevedavies.gmail.com

Eric Rizzo wrote:
> Steve Davies wrote:
>> Hi,
>>
>> I'm trying to create a basic File io reader to read from a text file
>> in Eclipse. I start with the usual try/catch block for IOExceptions.
>> here is an example of my code:
>>
>> FileReader fr = new FileReader("lorum.txt") //a simple txt file I have
>>
>> However in Eclipse at this stage I get a red underline error saying
>> "the constructor FileReader(String) is undefined."
>
> Check the import statement and make sure that the FileReader you are
> using is actually java.io.FileReader and not some other class in a
> different package.
>
> Hope this helps,
> Eric
Thanks Eric,

but i have tried both

import java.io.*;

and

import java.io.FileReader.*;

Ill keep trying
Re: FileReader() constructor issue in Eclipse?? [message #210461 is a reply to message #210440] Fri, 11 May 2007 15:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Steve Davies" <stedav.stevedavies@gmail.com> wrote in message
news:f21t87$t1h$1@build.eclipse.org...
> but i have tried both
>
> import java.io.*;
>
> and
>
> import java.io.FileReader.*;

If you type "FileReader f;" and Ctrl+click on the FileReader typename, does
it jump you to the expected class, and does that class show a String
constructor?

For what it's worth, in Eclipse 3.2.2 I have no problem using the String
constructor for FileReader; e.g., the following class compiles:

import java.io.*;

public class Foo {
void foo() {
FileReader f = null;
try {
f = new FileReader("foo.txt");
f.reset();
} catch (IOException e) {
// ignore
} finally {
try {
if (null != f) {
f.close();
}
} catch (IOException e) {
// ignore
}
}
}
}


So I think it must be something funky going on either with your code or with
the JRE you are using.

What version of Eclipse are you using, and what JRE is on your project's
build path?
Re: FileReader() constructor issue in Eclipse?? [message #1276360 is a reply to message #210374] Mon, 24 March 2014 13:05 Go to previous message
Zak Knill is currently offline Zak KnillFriend
Messages: 1
Registered: March 2014
Junior Member
I have this issue, and it was because my Class that contained the code was called FileReader.
Previous Topic:Parallel Runtime Perspective is missing in Eclipse Kepler
Next Topic:Open file in view plug-in
Goto Forum:
  


Current Time: Sun Dec 22 03:02:23 GMT 2024

Powered by FUDForum. Page generated in 0.07567 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top