[SOLVED] Import java.io.* problem
Why doesn't "import java.io.*;" import FileReader and FileWriter? It seems to do so for other classes.
Unless I explicitly import FileWriter (ie: with "import java.io.FileWriter;"), the code below gives the following compiler errors:
ImportTest.java:8: cannot find symbol
symbol : constructor FileWriter(java.io.File)
location: class FileWriter
FileWriter fw = new FileWriter(f);
ImportTest.java:9: cannot find symbol
symbol : method close()
location: class FileWriter
fw.close();
Code:
import java.io.*;
class ImportTest
{
public static void main(String[] args) throws IOException
{
File f = new File("Test.txt");
FileWriter fw = new FileWriter(f);
fw.close();
}
}
I could use java.io.File, java.io.FileWriter and java.io.IOException but I'm puzzled as to why the import doesn't appear to be working as I expect it to.
I'm working through examples in a book and the code above is a stripped-down version of the example in the book which gives the same errors.
What have I missed?