• Post Reply Bookmark Topic Watch Topic
  • New Topic

Methods in File Class  RSS feed

 
swati bannore
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Hush,i am studing I/O.I am not sure about following methods.
How do I make use of following method practically-
File[] listFiles();
boolean createNewFile();
boolean mkdir()
boolean mkdirs()
Any examples? for eg.how do i create a new File using createNewFile() method? How do I specify a name for file.?
Thanx
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Swati,
When you want examples you should try and do a search using the search function of this site. It really works and it works well! It really gets tedious answering the same questions everyday ...
I have already given a great example on the java.io.File functions.
See here http://www.javaranch.com/ubb/Forum24/HTML/007362.html
Regards,
Manfred.
[This message has been edited by Manfred Leonhardt (edited July 30, 2001).]
 
swati bannore
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx manfred.
I can understand ur situation
 
swati bannore
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code gives error :
method createNewFile() not found in java.io.File

Where is it worng?
Thanx

[This message has been edited by swati bannore (edited July 30, 2001).]
 
Mini Pilla
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it this error??
Exception java.io.IOException must be caught, or it must be declared in the throws clause of this method.
If this is the case then put try and catch blocks.
HTH
Thanx
Rajani
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
createNewFile() was added in JDK 1.2. What version of the JDK are you running?
------------------
Tom - SCJP --- Co-Moderator of the Programmer Certification Forums
 
swati bannore
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess,Version is a problem. I am using Java 1.1.6
But otherwise, syntax is correct,rite?
Thanx.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!