Wednesday, March 09, 2005

One of these things is not like the others

Are these not equivalent?

copy(new FileInputStream(new File(".")), System.out);
copy(new File(".").toURL().openStream(), System.out);

Oddly, they are not.

The first line throws a FileNotFoundException (misleading as the error message states . (Access is denied)), whereas the second copies a sorted file listing, one file name per line. I learn something new every day.

Post a Comment