Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
555 views
in Technique[技术] by (71.8m points)

java - both File.isFile() and File.isDirectory() is returning false

I have a file with name "aaa?aa.xls"

For this, File.isFile() and File.isDirectory() is returning false? why it is returning false in Linux?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Please try the following code example

if(!pFile.exists()){
   throw new FileNotFoundException();
}

boolean isDir = pFile.isDirectory();

boolean isFile = pfile.isFile();

the file is not a file

if it is not a directory and, in addition, satisfies other system-dependent criteria

if the exception is thrown, you have to check the file path.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...