确定文件名路径是文件还是目录
import java.awt.Graphics; import java.io.File; /** from 时 代 J a v a 公 众 号 - N o w J a v a . c o m**/ public class Main { public void m() { File dir = new File("directoryName"); boolean isDir = dir.isDirectory(); if (isDir) { // dir is a directory } else { // dir is a file } } }