src/share/sample/nio/file/FileType.java

Print this page

        

@@ -28,11 +28,10 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 import java.nio.file.*;
-import java.nio.file.attribute.*;
 import java.io.IOException;
 
 public class FileType {
     public static void main(String[] args) throws IOException {
         if (args.length == 0) {

@@ -39,14 +38,12 @@
             System.err.println("usage: java FileType file...");
             System.exit(-1);
         }
         for (String arg: args) {
             Path file = Paths.get(arg);
-            BasicFileAttributes attrs = Attributes.readBasicFileAttributes(file);
-
             String type;
-            if (attrs.isDirectory()) {
+            if (Files.isDirectory(file)) {
                 type = "directory";
             } else {
                 type = Files.probeContentType(file);
                 if (type == null)
                     type = "<not recognized>";