Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Practice Tests for OCP Java 17 Certification Exam (1Z0-829)
this week in the
OCPJP
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Liutauras Vilda
Sheriffs:
Rob Spoor
Junilu Lacar
paul wheaton
Saloon Keepers:
Stephan van Hulst
Tim Moores
Tim Holloway
Carey Brown
Scott Selikoff
Bartenders:
Piet Souris
Jj Roberts
fred rosenberger
Forum:
Java in General
find whether the folder exists or not
Madhu Sudhana
Ranch Hand
Posts: 127
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
How can we find that
a floder exists or not in a particular location?
ex:
c:\folder1
I have to search folder1 exists in c:\ or not
let me know if any body has the answer??
"And the trouble is, if you don't risk anything, you risk even more." -- Erica Jong.
Edwin Dalorzo
Ranch Hand
Posts: 961
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The java.io.File class has a method exists().
A Kumar
Ranch Hand
Posts: 980
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public class DirectoryExists { public static void main(String[] args) { File f=new File("C:/folder1"); System.out.println("Exists " + f.isDirectory()); } }
Try this
exists....checks whether the input exists (it can be a file or a folder)
isDirectory..checks whether the input exists and if it exists....it should be a directory...
[ October 04, 2006: Message edited by: A Kumar ]
Madhu Sudhana
Ranch Hand
Posts: 127
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I got the answer
its simple
import java.io.File; class CheckFolder { public static void main(String[] args) { File folderExisting = new File("C:\\folder1"); if (folderExisting.exists()){ System.out.println("Floder exists"); }else{ System.out.println("Floder not exists"); } } }
[ October 04, 2006: Message edited by: sudhana madhu ]
"And the trouble is, if you don't risk anything, you risk even more." -- Erica Jong.
You may have just won ten million dollars! Or, maybe a tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Create folder
weblogic
creating a tree in JSP
Package does not exist
diference between mkdirs and mkdirs?
More...