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 is wrapper class example?
Can subclass overriding method declare an exception if parent class method doesn't throw an exception?
What is the multi-catch block in java?
How do you find the absolute value?
Explain the key functions of data binding?
What is math in java?
What is set string?
What are heap memory and stack memory and what are memory tables.
What is the purpose of static methods and static variables?
How many bits is size_t?
how can you take care of mutual exclusion using java threads? : Java thread
What is the old name of java?
What is the purpose of the wait(), notify(), and notifyall() methods in java programming?
What is the main difference between java platform and other platforms?
What is the purpose of the finalize() method?