I can't see the error

S

Stefan Ram

I wrote:

public static void mergeContentsOf
( final java.nio.file.Path source,
final java.lang.String description,
final java.nio.file.Path newTarget )
throws java.lang.Exception
{ final java.nio.file.DirectoryStream directoryStream =
source.newDirectoryStream( "*" );
try
{ for( final java.nio.file.Path path : directoryStream )
{ merge( path, description, newTarget ); }}
finally
{ directoryStream.close(); }}

, the compiler replied:

Main.java:9: incompatible types
{ for( final java.nio.file.Path path : directoryStream )
^
required: Path
found: Object
1 error

, but I can't see any expression of type »Object«.

$javac -version -verbose
javac 1.7.0-ea
 
M

Michael Jung

public static void mergeContentsOf
( final java.nio.file.Path source,
final java.lang.String description,
final java.nio.file.Path newTarget )
throws java.lang.Exception
{ final java.nio.file.DirectoryStream directoryStream =
source.newDirectoryStream( "*" );
try
{ for( final java.nio.file.Path path : directoryStream )
{ merge( path, description, newTarget ); }}
finally
{ directoryStream.close(); }}

, the compiler replied:

Main.java:9: incompatible types
{ for( final java.nio.file.Path path : directoryStream )
^
required: Path
found: Object
1 error

, but I can't see any expression of type »Object«.

$javac -version -verbose
javac 1.7.0-ea

DirectoryStream returns an untyped iterator, ie. one which gives you an
"Object" for each step. (And this is behind the java-shorthand ":"
notation.)

Michael
 
A

Andreas Leitgeb

Stefan Ram said:
public static void mergeContentsOf
( final java.nio.file.Path source,
final java.lang.String description,
final java.nio.file.Path newTarget )
throws java.lang.Exception
{ final java.nio.file.DirectoryStream directoryStream =
source.newDirectoryStream( "*" );
try
{ for( final java.nio.file.Path path : directoryStream )

Just guessing:
final java.nio.file.DirectoryStream<Path> directoryStream =

Don't have 1.7 here to test myself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top