import java.io.*;
class Demo
{
public static void main(String args[])
{
File f=new File("1234.msg");
String arr[]=f.list();
System.out.println(arr.length);
}
}
Answer Posted / meziane
The list() of the class java.io.File "returns an array of Strings naming the files and directories in the directory denoted by this abstract pathname."
http://docs.oracle.com/javase/6/docs/api/java/io/File.html#list%28%29
The abstract pathname is the path specified in File f = new File(patAsString).
The method returns null, if the abstract pathname does not denote a directory (i.e an existing directory).
No compilation error.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What about member inner classes?
Explain yield() method in thread class ?
what is a green thread? : Java thread
Name component subclasses that support painting in java programming?
How can constructor chaining be done by using the super keyword?
What are the 6 boolean operators?
What is a string token?
What isan abstract class and when do you use it?
What is replacefirst in java?
What is the class in java?
Explain the difference between static and dynamic binding in java?
What is data type in java?
What is thread safe in java?
How does varargs work in java?
What is the difference between == and === javascript?