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
Can we start a thread twice in java?
Explain the difference between collection api and stream api in java8?
What is singleton service?
Explain an algorithm to find depth of a binary tree.
Is main is a keyword?
What is boolean example?
Difference between default and protected access specifiers?
What is number data type in java?
Why does java have two ways to create child threads?
How do you replace a string in java?
Which variables are stored in heap?
Can we define static methods inside interface?
What is finalize()?
what are different ways in which a thread can enter the waiting state? : Java thread
Name some OOPS Concepts in Java?