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 is the difference between public, private, protected, and friend access?

570


Can you give few examples of final classes defined in java api?

559


What is an enumeration?

566


Can we use string in the switch case?

575


Where pragma is used?

594






What is local declaration?

489


Does A Class Inherit The Constructors Of Its Superclass?

536


Difference between this() and super() in java ?

611


Define reflection.

575


What is integers and example?

486


Why constructor has no return type?

636


Does java runtime require a license?

574


What sorting algorithm does javascript use?

526


Give us the name of the list layoutmanagers in java?

522


Java Compiler is stored in JDK, JRE or JVM?

1050