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 time complexity java?
Is java programming easy?
List some features of the abstract class.
What is the difference between arraylist and hashset in java?
What is the difference between JVM and JRE?
Why parsing is done?
What methodology can be utilized to link to a database?
Can list have duplicates in java?
Is null function in java?
Explain about doubly linked list
What does %d do in java?
How is string immutable in java?
Can we extend a class with private constructor?
Write a function to find out longest palindrome in a given string?
How do you get the length of a string in java?