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


Please Help Members By Posting Answers For Below Questions

What are 3 boolean operators?

546


Is char a method in java?

527


How does thread synchronization occurs inside a monitor?

562


What is meant by data hiding in java?

644


What is natural ordering in java?

540






What access modifiers can be used for class ?

552


Is empty in java?

588


Can constructor be synchronized?

555


What is string in java? String is a data type?

586


What is variable in java?

535


What is return used for in java?

530


What is the use of System class?

624


Why is java called java?

551


Can abstract class have private constructor?

508


What is composition in java?

732