Jay
Jay

Reputation: 185

Cannot find symbole - class file

I'm creating a class that implements DirectoryStream so I can iterate through a directory. However, I am not able to get beyond compile time errors because, when I try to import "java.nio.file", it states "cannot find symbol - class file". Does anyone have a clue why?

    import java.nio.file;
                   ^ to ^ is highlighted red when I compile the file.

Upvotes: 0

Views: 1050

Answers (2)

Andreas Dolk
Andreas Dolk

Reputation: 114757

The statement

import java.nio.file;

tries to import the class named file from the package java.nio. Which obviously doesn't exist (in the JRE).

In you code, the statement should be

import java.nio.file.DirectoryStream;

(and double check that you're using Java 7, it's not available in previous versions)

Upvotes: 0

PermGenError
PermGenError

Reputation: 46398

it should be

import java.nio.file.*;

java.nio.file is a package not a class

Upvotes: 4

Related Questions