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
When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?
How to convert string to char and vice versa?
What is oops in java?
Explain the use of javap tool.
What is not thread safe?
What is bool mean?
What is nullpointerexception in java?
What is the purpose of garbage collection in java, and when is it used?
java program with complete 4 oops concepts implemented example
What do u mean by variable?
Can we cast any other type to boolean type with type casting?
How to optimize the javac output?
What is flag in python?
Can a constructor be protected?
What is meant by method overriding?