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 the difference between public, private, protected, and friend access?
Can you give few examples of final classes defined in java api?
What is an enumeration?
Can we use string in the switch case?
Where pragma is used?
What is local declaration?
Does A Class Inherit The Constructors Of Its Superclass?
Difference between this() and super() in java ?
Define reflection.
What is integers and example?
Why constructor has no return type?
Does java runtime require a license?
What sorting algorithm does javascript use?
Give us the name of the list layoutmanagers in java?
Java Compiler is stored in JDK, JRE or JVM?