@@ -0,0 +1,1428 @@
+package com.levelup.java.io;%0A%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.net.URISyntaxException;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0Aimport java.nio.file.attribute.BasicFileAttributes;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0A/**%0A * This java example will demonstrate how to check %0A * if a file is a directory.%0A * %0A * @author Justin Musgrove%0A * @see %3Ca href='http://www.leveluplunch.com/java/examples/determine-if-file-is-directory/'%3EIs file a directory%3C/a%3E%0A */%0Apublic class IsFileDirectory %7B%0A%0A%09private static final String SOURCE = %22com/levelup/java/io%22;%0A%09%0A%09Path source;%0A%09%0A%09@Before%0A%09public void setUp() throws IOException, URISyntaxException %7B%0A%0A%09%09source = Paths.get(this.getClass().getClassLoader().getResource(SOURCE)%0A%09%09%09%09.toURI());%0A%09%7D%0A%09%0A%09@Test%0A%09public void file_is_directory_java () %7B%0A%09%09%0A%09%09File file = source.toFile();%0A%09%09%0A%09%09boolean isFileADirectory = file.isDirectory();%0A%09%09%0A%09%09assertTrue(isFileADirectory);%09%0A%09%7D%0A%09%0A%09@Test%0A%09public void file_is_directory_nio() throws IOException %7B%0A%0A%09%09BasicFileAttributes attr = Files.readAttributes(source,%0A%09%09%09%09BasicFileAttributes.class);%0A%0A%09%09boolean isFileADirectory = attr.isDirectory();%0A%0A%09%09assertTrue(isFileADirectory);%0A%09%7D%0A%09%0A%09@Test%0A%09public void file_is_directory_nio_files () %7B%0A%09%09%0A%09%09boolean isFileADirectory = Files.isDirectory(source);%0A%0A%09%09assertTrue(isFileADirectory);%0A%09%7D%0A%09%0A%7D%0A

add java example how to check if a file is a directory